Refactor IPC services to have commands into separate classes, fix readme url

This commit is contained in:
gdkchan 2018-02-25 01:34:16 -03:00
parent a4ff0d3484
commit fba0bf8732
73 changed files with 825 additions and 583 deletions

View file

@ -67,4 +67,4 @@ Run `dotnet run -c Release -- path\to\game_exefs_and_romfs_folder` to run offici
**Latest build** **Latest build**
These builds are compiled automatically for each commit on the master branch. They may be unstable or not work at all. These builds are compiled automatically for each commit on the master branch. They may be unstable or not work at all.
To download the latest automatic build for Windows (64-bits), [Click Here](https://ci.appveyor.com/api/projects/gdkchan/ryujinx/artifacts/ryujinx_latest_unstable.zip). To download the latest automatic build for Windows (64-bits), [Click Here](https://ci.appveyor.com/api/projects/gdkchan/ryujinx/artifacts/ryujinx_latest_unstable.zip?pr=false).

View file

@ -1,21 +1,23 @@
using Ryujinx.Core.OsHle.IpcServices;
namespace Ryujinx.Core.OsHle.Handles namespace Ryujinx.Core.OsHle.Handles
{ {
class HSession class HSession
{ {
public string ServiceName { get; private set; } public IIpcService Service { get; private set; }
public bool IsInitialized { get; private set; } public bool IsInitialized { get; private set; }
public int State { get; set; } public int State { get; set; }
public HSession(string ServiceName) public HSession(IIpcService Service)
{ {
this.ServiceName = ServiceName; this.Service = Service;
} }
public HSession(HSession Session) public HSession(HSession Session)
{ {
ServiceName = Session.ServiceName; Service = Session.Service;
IsInitialized = Session.IsInitialized; IsInitialized = Session.IsInitialized;
} }

View file

@ -1,79 +1,13 @@
using ChocolArm64.Memory; using ChocolArm64.Memory;
using Ryujinx.Core.OsHle.Handles; using Ryujinx.Core.OsHle.Handles;
using Ryujinx.Core.OsHle.Objects; using Ryujinx.Core.OsHle.IpcServices;
using Ryujinx.Core.OsHle.Services;
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
namespace Ryujinx.Core.OsHle.Ipc namespace Ryujinx.Core.OsHle.Ipc
{ {
static class IpcHandler static class IpcHandler
{ {
private static Dictionary<(string, int), ServiceProcessRequest> ServiceCmds =
new Dictionary<(string, int), ServiceProcessRequest>()
{
{ ( "acc:u0", 3), Service.AccU0ListOpenUsers },
{ ( "acc:u0", 5), Service.AccU0GetProfile },
{ ( "acc:u0", 100), Service.AccU0InitializeApplicationInfo },
{ ( "acc:u0", 101), Service.AccU0GetBaasAccountManagerForApplication },
{ ( "apm", 0), Service.ApmOpenSession },
{ ( "apm:p", 0), Service.ApmOpenSession },
{ ( "appletOE", 0), Service.AppletOpenApplicationProxy },
{ ( "audout:u", 0), Service.AudOutListAudioOuts },
{ ( "audout:u", 1), Service.AudOutOpenAudioOut },
{ ( "audren:u", 0), Service.AudRenOpenAudioRenderer },
{ ( "audren:u", 1), Service.AudRenGetAudioRendererWorkBufferSize },
{ ( "friend:a", 0), Service.FriendCreateFriendService },
{ ( "fsp-srv", 1), Service.FspSrvInitialize },
{ ( "fsp-srv", 18), Service.FspSrvMountSdCard },
{ ( "fsp-srv", 51), Service.FspSrvMountSaveData },
{ ( "fsp-srv", 200), Service.FspSrvOpenDataStorageByCurrentProcess },
{ ( "fsp-srv", 203), Service.FspSrvOpenRomStorage },
{ ( "fsp-srv", 1005), Service.FspSrvGetGlobalAccessLogMode },
{ ( "hid", 0), Service.HidCreateAppletResource },
{ ( "hid", 11), Service.HidActivateTouchScreen },
{ ( "hid", 100), Service.HidSetSupportedNpadStyleSet },
{ ( "hid", 101), Service.HidGetSupportedNpadStyleSet },
{ ( "hid", 102), Service.HidSetSupportedNpadIdType },
{ ( "hid", 103), Service.HidActivateNpad },
{ ( "hid", 120), Service.HidSetNpadJoyHoldType },
{ ( "hid", 121), Service.HidGetNpadJoyHoldType },
{ ( "hid", 203), Service.HidCreateActiveVibrationDeviceList },
{ ( "lm", 0), Service.LmInitialize },
{ ( "nvdrv", 0), Service.NvDrvOpen },
{ ( "nvdrv", 1), Service.NvDrvIoctl },
{ ( "nvdrv", 2), Service.NvDrvClose },
{ ( "nvdrv", 3), Service.NvDrvInitialize },
{ ( "nvdrv", 4), Service.NvDrvQueryEvent },
{ ( "nvdrv", 8), Service.NvDrvSetClientPid },
{ ( "nvdrv:a", 0), Service.NvDrvOpen },
{ ( "nvdrv:a", 1), Service.NvDrvIoctl },
{ ( "nvdrv:a", 2), Service.NvDrvClose },
{ ( "nvdrv:a", 3), Service.NvDrvInitialize },
{ ( "nvdrv:a", 4), Service.NvDrvQueryEvent },
{ ( "nvdrv:a", 8), Service.NvDrvSetClientPid },
{ ( "pctl:a", 0), Service.PctlCreateService },
{ ( "pl:u", 1), Service.PlGetLoadState },
{ ( "pl:u", 2), Service.PlGetFontSize },
{ ( "pl:u", 3), Service.PlGetSharedMemoryAddressOffset },
{ ( "pl:u", 4), Service.PlGetSharedMemoryNativeHandle },
{ ( "set", 1), Service.SetGetAvailableLanguageCodes },
{ ( "sm:", 0), Service.SmInitialize },
{ ( "sm:", 1), Service.SmGetService },
{ ( "time:u", 0), Service.TimeGetStandardUserSystemClock },
{ ( "time:u", 1), Service.TimeGetStandardNetworkSystemClock },
{ ( "time:u", 2), Service.TimeGetStandardSteadyClock },
{ ( "time:u", 3), Service.TimeGetTimeZoneService },
{ ( "time:u", 4), Service.TimeGetStandardLocalSystemClock },
{ ( "time:s", 0), Service.TimeGetStandardUserSystemClock },
{ ( "time:s", 1), Service.TimeGetStandardNetworkSystemClock },
{ ( "time:s", 2), Service.TimeGetStandardSteadyClock },
{ ( "time:s", 3), Service.TimeGetTimeZoneService },
{ ( "time:s", 4), Service.TimeGetStandardLocalSystemClock },
{ ( "vi:m", 2), Service.ViGetDisplayService },
};
private const long SfciMagic = 'S' << 0 | 'F' << 8 | 'C' << 16 | 'I' << 24; private const long SfciMagic = 'S' << 0 | 'F' << 8 | 'C' << 16 | 'I' << 24;
private const long SfcoMagic = 'S' << 0 | 'F' << 8 | 'C' << 16 | 'O' << 24; private const long SfcoMagic = 'S' << 0 | 'F' << 8 | 'C' << 16 | 'O' << 24;
@ -94,7 +28,7 @@ namespace Ryujinx.Core.OsHle.Ipc
if (Request.Type == IpcMessageType.Request) if (Request.Type == IpcMessageType.Request)
{ {
string ServiceName = Session.ServiceName; string ServiceName = Session.Service.GetType().Name;
ServiceProcessRequest ProcReq = null; ServiceProcessRequest ProcReq = null;
@ -113,13 +47,13 @@ namespace Ryujinx.Core.OsHle.Ipc
if (Obj is HDomain) if (Obj is HDomain)
{ {
ServiceCmds.TryGetValue((ServiceName, CmdId), out ProcReq); Session.Service.Commands.TryGetValue(CmdId, out ProcReq);
DbgServiceName = $"{ProcReq?.Method.Name ?? CmdId.ToString()}"; DbgServiceName = $"{ProcReq?.Method.Name ?? CmdId.ToString()}";
} }
else if (Obj != null) else if (Obj != null)
{ {
((IIpcInterface)Obj).Commands.TryGetValue(CmdId, out ProcReq); ((IIpcService)Obj).Commands.TryGetValue(CmdId, out ProcReq);
DbgServiceName = $"{Obj.GetType().Name} {ProcReq?.Method.Name ?? CmdId.ToString()}"; DbgServiceName = $"{Obj.GetType().Name} {ProcReq?.Method.Name ?? CmdId.ToString()}";
} }
@ -142,13 +76,13 @@ namespace Ryujinx.Core.OsHle.Ipc
{ {
object Obj = ((HSessionObj)Session).Obj; object Obj = ((HSessionObj)Session).Obj;
((IIpcInterface)Obj).Commands.TryGetValue(CmdId, out ProcReq); ((IIpcService)Obj).Commands.TryGetValue(CmdId, out ProcReq);
DbgServiceName = $"{Obj.GetType().Name} {ProcReq?.Method.Name ?? CmdId.ToString()}"; DbgServiceName = $"{Obj.GetType().Name} {ProcReq?.Method.Name ?? CmdId.ToString()}";
} }
else else
{ {
ServiceCmds.TryGetValue((ServiceName, CmdId), out ProcReq); Session.Service.Commands.TryGetValue(CmdId, out ProcReq);
DbgServiceName = $"{ProcReq?.Method.Name ?? CmdId.ToString()}"; DbgServiceName = $"{ProcReq?.Method.Name ?? CmdId.ToString()}";
} }

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Acc namespace Ryujinx.Core.OsHle.IpcServices.Acc
{ {
class IManagerForApplication : IIpcInterface class IManagerForApplication : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Acc namespace Ryujinx.Core.OsHle.IpcServices.Acc
{ {
class IProfile : IIpcInterface class IProfile : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -0,0 +1,49 @@
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
namespace Ryujinx.Core.OsHle.IpcServices.Acc
{
class ServiceAcc : IIpcService
{
private Dictionary<int, ServiceProcessRequest> m_Commands;
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public ServiceAcc()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 3, ListOpenUsers },
{ 5, GetProfile },
{ 100, InitializeApplicationInfo },
{ 101, GetBaasAccountManagerForApplication }
};
}
public long ListOpenUsers(ServiceCtx Context)
{
return 0;
}
public long GetProfile(ServiceCtx Context)
{
MakeObject(Context, new IProfile());
return 0;
}
public long InitializeApplicationInfo(ServiceCtx Context)
{
return 0;
}
public long GetBaasAccountManagerForApplication(ServiceCtx Context)
{
MakeObject(Context, new IManagerForApplication());
return 0;
}
}
}

View file

@ -2,11 +2,11 @@ using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using static Ryujinx.Core.OsHle.Objects.ObjHelper; using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
namespace Ryujinx.Core.OsHle.Objects.Am namespace Ryujinx.Core.OsHle.IpcServices.Am
{ {
class IApplicationFunctions : IIpcInterface class IApplicationFunctions : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -1,11 +1,11 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
using static Ryujinx.Core.OsHle.Objects.ObjHelper; using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
namespace Ryujinx.Core.OsHle.Objects.Am namespace Ryujinx.Core.OsHle.IpcServices.Am
{ {
class IApplicationProxy : IIpcInterface class IApplicationProxy : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Am namespace Ryujinx.Core.OsHle.IpcServices.Am
{ {
class IAudioController : IIpcInterface class IAudioController : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Am namespace Ryujinx.Core.OsHle.IpcServices.Am
{ {
class ICommonStateGetter : IIpcInterface class ICommonStateGetter : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Am namespace Ryujinx.Core.OsHle.IpcServices.Am
{ {
class IDebugFunctions : IIpcInterface class IDebugFunctions : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Am namespace Ryujinx.Core.OsHle.IpcServices.Am
{ {
class IDisplayController : IIpcInterface class IDisplayController : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Am namespace Ryujinx.Core.OsHle.IpcServices.Am
{ {
class ILibraryAppletCreator : IIpcInterface class ILibraryAppletCreator : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Am namespace Ryujinx.Core.OsHle.IpcServices.Am
{ {
class ISelfController : IIpcInterface class ISelfController : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -1,11 +1,11 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
using static Ryujinx.Core.OsHle.Objects.ObjHelper; using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
namespace Ryujinx.Core.OsHle.Objects.Am namespace Ryujinx.Core.OsHle.IpcServices.Am
{ {
class IStorage : IIpcInterface class IStorage : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -3,9 +3,9 @@ using Ryujinx.Core.OsHle.Ipc;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Am namespace Ryujinx.Core.OsHle.IpcServices.Am
{ {
class IStorageAccessor : IIpcInterface class IStorageAccessor : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Am namespace Ryujinx.Core.OsHle.IpcServices.Am
{ {
class IWindowController : IIpcInterface class IWindowController : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -0,0 +1,29 @@
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
namespace Ryujinx.Core.OsHle.IpcServices.Am
{
class ServiceAppletOE : IIpcService
{
private Dictionary<int, ServiceProcessRequest> m_Commands;
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public ServiceAppletOE()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 0, OpenApplicationProxy }
};
}
public long OpenApplicationProxy(ServiceCtx Context)
{
MakeObject(Context, new IApplicationProxy());
return 0;
}
}
}

View file

@ -1,6 +1,6 @@
using System.IO; using System.IO;
namespace Ryujinx.Core.OsHle.Objects.Android namespace Ryujinx.Core.OsHle.IpcServices.Android
{ {
struct GbpBuffer struct GbpBuffer
{ {

View file

@ -6,9 +6,9 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using static Ryujinx.Core.OsHle.Objects.Android.Parcel; using static Ryujinx.Core.OsHle.IpcServices.Android.Parcel;
namespace Ryujinx.Core.OsHle.Objects.Android namespace Ryujinx.Core.OsHle.IpcServices.Android
{ {
class NvFlinger : IDisposable class NvFlinger : IDisposable
{ {

View file

@ -1,7 +1,7 @@
using System; using System;
using System.IO; using System.IO;
namespace Ryujinx.Core.OsHle.Objects.Android namespace Ryujinx.Core.OsHle.IpcServices.Android
{ {
static class Parcel static class Parcel
{ {

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Apm namespace Ryujinx.Core.OsHle.IpcServices.Apm
{ {
class ISession : IIpcInterface class ISession : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -0,0 +1,29 @@
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
namespace Ryujinx.Core.OsHle.IpcServices.Apm
{
class ServiceApm : IIpcService
{
private Dictionary<int, ServiceProcessRequest> m_Commands;
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public ServiceApm()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 0, OpenSession }
};
}
public long OpenSession(ServiceCtx Context)
{
MakeObject(Context, new ISession());
return 0;
}
}
}

View file

@ -7,9 +7,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
namespace Ryujinx.Core.OsHle.Objects.Aud namespace Ryujinx.Core.OsHle.IpcServices.Aud
{ {
class IAudioOut : IIpcInterface class IAudioOut : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -2,9 +2,9 @@ using Ryujinx.Core.OsHle.Handles;
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Aud namespace Ryujinx.Core.OsHle.IpcServices.Aud
{ {
class IAudioRenderer : IIpcInterface class IAudioRenderer : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -0,0 +1,57 @@
using ChocolArm64.Memory;
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
using System.Text;
using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
namespace Ryujinx.Core.OsHle.IpcServices.Aud
{
class ServiceAudOut : IIpcService
{
private Dictionary<int, ServiceProcessRequest> m_Commands;
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public ServiceAudOut()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 0, ListAudioOuts },
{ 1, OpenAudioOut },
};
}
public long ListAudioOuts(ServiceCtx Context)
{
long Position = Context.Request.ReceiveBuff[0].Position;
AMemoryHelper.WriteBytes(Context.Memory, Position, Encoding.ASCII.GetBytes("iface"));
Context.ResponseData.Write(1);
return 0;
}
public long OpenAudioOut(ServiceCtx Context)
{
MakeObject(Context, new IAudioOut());
Context.ResponseData.Write(48000); //Sample Rate
Context.ResponseData.Write(2); //Channel Count
Context.ResponseData.Write(2); //PCM Format
/*
0 - Invalid
1 - INT8
2 - INT16
3 - INT24
4 - INT32
5 - PCM Float
6 - ADPCM
*/
Context.ResponseData.Write(0); //Unknown
return 0;
}
}
}

View file

@ -0,0 +1,51 @@
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
namespace Ryujinx.Core.OsHle.IpcServices.Aud
{
class ServiceAudRen : IIpcService
{
private Dictionary<int, ServiceProcessRequest> m_Commands;
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public ServiceAudRen()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 0, OpenAudioRenderer },
{ 1, GetAudioRendererWorkBufferSize },
};
}
public long OpenAudioRenderer(ServiceCtx Context)
{
MakeObject(Context, new IAudioRenderer());
return 0;
}
public long GetAudioRendererWorkBufferSize(ServiceCtx Context)
{
int SampleRate = Context.RequestData.ReadInt32();
int Unknown4 = Context.RequestData.ReadInt32();
int Unknown8 = Context.RequestData.ReadInt32();
int UnknownC = Context.RequestData.ReadInt32();
int Unknown10 = Context.RequestData.ReadInt32();
int Unknown14 = Context.RequestData.ReadInt32();
int Unknown18 = Context.RequestData.ReadInt32();
int Unknown1c = Context.RequestData.ReadInt32();
int Unknown20 = Context.RequestData.ReadInt32();
int Unknown24 = Context.RequestData.ReadInt32();
int Unknown28 = Context.RequestData.ReadInt32();
int Unknown2c = Context.RequestData.ReadInt32();
int Rev1Magic = Context.RequestData.ReadInt32();
Context.ResponseData.Write(0x400L);
return 0;
}
}
}

View file

@ -1,4 +1,4 @@
namespace Ryujinx.Core.OsHle.Objects namespace Ryujinx.Core.OsHle.IpcServices
{ {
static class ErrorCode static class ErrorCode
{ {

View file

@ -1,4 +1,4 @@
namespace Ryujinx.Core.OsHle.Objects namespace Ryujinx.Core.OsHle.IpcServices
{ {
enum ErrorModule enum ErrorModule
{ {

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Friend namespace Ryujinx.Core.OsHle.IpcServices.Friend
{ {
class IFriendService : IIpcInterface class IFriendService : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -0,0 +1,29 @@
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
namespace Ryujinx.Core.OsHle.IpcServices.Friend
{
class ServiceFriend : IIpcService
{
private Dictionary<int, ServiceProcessRequest> m_Commands;
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public ServiceFriend()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 0, CreateFriendService }
};
}
public static long CreateFriendService(ServiceCtx Context)
{
MakeObject(Context, new IFriendService());
return 0;
}
}
}

View file

@ -1,4 +1,4 @@
namespace Ryujinx.Core.OsHle.Objects.FspSrv namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
{ {
static class FsErr static class FsErr
{ {

View file

@ -5,9 +5,9 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
namespace Ryujinx.Core.OsHle.Objects.FspSrv namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
{ {
class IDirectory : IIpcInterface, IDisposable class IDirectory : IIpcService, IDisposable
{ {
private const int DirectoryEntrySize = 0x310; private const int DirectoryEntrySize = 0x310;

View file

@ -4,9 +4,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
namespace Ryujinx.Core.OsHle.Objects.FspSrv namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
{ {
class IFile : IIpcInterface, IDisposable class IFile : IIpcService, IDisposable
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -4,12 +4,12 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using static Ryujinx.Core.OsHle.Objects.ErrorCode; using static Ryujinx.Core.OsHle.IpcServices.ErrorCode;
using static Ryujinx.Core.OsHle.Objects.ObjHelper; using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
namespace Ryujinx.Core.OsHle.Objects.FspSrv namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
{ {
class IFileSystem : IIpcInterface class IFileSystem : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -3,9 +3,9 @@ using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
namespace Ryujinx.Core.OsHle.Objects.FspSrv namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
{ {
class IStorage : IIpcInterface class IStorage : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -0,0 +1,67 @@
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
namespace Ryujinx.Core.OsHle.IpcServices.FspSrv
{
class ServiceFspSrv : IIpcService
{
private Dictionary<int, ServiceProcessRequest> m_Commands;
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public ServiceFspSrv()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 1, Initialize },
{ 18, MountSdCard },
{ 51, MountSaveData },
{ 200, OpenDataStorageByCurrentProcess },
{ 203, OpenRomStorage },
{ 1005, GetGlobalAccessLogMode }
};
}
public long Initialize(ServiceCtx Context)
{
return 0;
}
public long MountSdCard(ServiceCtx Context)
{
MakeObject(Context, new IFileSystem(Context.Ns.VFs.GetSdCardPath()));
return 0;
}
public long MountSaveData(ServiceCtx Context)
{
MakeObject(Context, new IFileSystem(Context.Ns.VFs.GetGameSavesPath()));
return 0;
}
public long OpenDataStorageByCurrentProcess(ServiceCtx Context)
{
MakeObject(Context, new IStorage(Context.Ns.VFs.RomFs));
return 0;
}
public long OpenRomStorage(ServiceCtx Context)
{
MakeObject(Context, new IStorage(Context.Ns.VFs.RomFs));
return 0;
}
public long GetGlobalAccessLogMode(ServiceCtx Context)
{
Context.ResponseData.Write(0);
return 0;
}
}
}

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Hid namespace Ryujinx.Core.OsHle.IpcServices.Hid
{ {
class IActiveApplicationDeviceList : IIpcInterface class IActiveApplicationDeviceList : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -2,9 +2,9 @@ using Ryujinx.Core.OsHle.Handles;
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Hid namespace Ryujinx.Core.OsHle.IpcServices.Hid
{ {
class IAppletResource : IIpcInterface class IAppletResource : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -0,0 +1,98 @@
using Ryujinx.Core.OsHle.Handles;
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
namespace Ryujinx.Core.OsHle.IpcServices.Hid
{
class ServiceHid : IIpcService
{
private Dictionary<int, ServiceProcessRequest> m_Commands;
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public ServiceHid()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 0, CreateAppletResource },
{ 11, ActivateTouchScreen },
{ 100, SetSupportedNpadStyleSet },
{ 101, GetSupportedNpadStyleSet },
{ 102, SetSupportedNpadIdType },
{ 103, ActivateNpad },
{ 120, SetNpadJoyHoldType },
{ 121, GetNpadJoyHoldType },
{ 203, CreateActiveVibrationDeviceList },
};
}
public long CreateAppletResource(ServiceCtx Context)
{
HSharedMem HidHndData = Context.Ns.Os.Handles.GetData<HSharedMem>(Context.Ns.Os.HidHandle);
MakeObject(Context, new IAppletResource(HidHndData));
return 0;
}
public long ActivateTouchScreen(ServiceCtx Context)
{
long Unknown = Context.RequestData.ReadInt64();
return 0;
}
public long GetSupportedNpadStyleSet(ServiceCtx Context)
{
Context.ResponseData.Write(0);
return 0;
}
public long SetSupportedNpadStyleSet(ServiceCtx Context)
{
long Unknown0 = Context.RequestData.ReadInt64();
long Unknown8 = Context.RequestData.ReadInt64();
return 0;
}
public long SetSupportedNpadIdType(ServiceCtx Context)
{
long Unknown = Context.RequestData.ReadInt64();
return 0;
}
public long ActivateNpad(ServiceCtx Context)
{
long Unknown = Context.RequestData.ReadInt64();
return 0;
}
public long SetNpadJoyHoldType(ServiceCtx Context)
{
long Unknown0 = Context.RequestData.ReadInt64();
long Unknown8 = Context.RequestData.ReadInt64();
return 0;
}
public long GetNpadJoyHoldType(ServiceCtx Context)
{
Context.ResponseData.Write(0L);
return 0;
}
public long CreateActiveVibrationDeviceList(ServiceCtx Context)
{
MakeObject(Context, new IActiveApplicationDeviceList());
return 0;
}
}
}

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects namespace Ryujinx.Core.OsHle.IpcServices
{ {
interface IIpcInterface interface IIpcService
{ {
IReadOnlyDictionary<int, ServiceProcessRequest> Commands { get; } IReadOnlyDictionary<int, ServiceProcessRequest> Commands { get; }
} }

View file

@ -0,0 +1,27 @@
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.IpcServices.Lm
{
class ServiceLm : IIpcService
{
private Dictionary<int, ServiceProcessRequest> m_Commands;
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public ServiceLm()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 0, Initialize }
};
}
public long Initialize(ServiceCtx Context)
{
Context.Session.Initialize();
return 0;
}
}
}

View file

@ -6,14 +6,14 @@ using Ryujinx.Graphics.Gpu;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Services namespace Ryujinx.Core.OsHle.IpcServices.NvServices
{ {
static partial class Service class ServiceNvDrv : IIpcService
{ {
private delegate long ServiceProcessRequest(ServiceCtx Context); private delegate long ServiceProcessIoctl(ServiceCtx Context);
private static Dictionary<(string, int), ServiceProcessRequest> IoctlCmds = private static Dictionary<(string, int), ServiceProcessIoctl> IoctlCmds =
new Dictionary<(string, int), ServiceProcessRequest>() new Dictionary<(string, int), ServiceProcessIoctl>()
{ {
{ ("/dev/nvhost-as-gpu", 0x4101), NvGpuAsIoctlBindChannel }, { ("/dev/nvhost-as-gpu", 0x4101), NvGpuAsIoctlBindChannel },
{ ("/dev/nvhost-as-gpu", 0x4102), NvGpuAsIoctlAllocSpace }, { ("/dev/nvhost-as-gpu", 0x4102), NvGpuAsIoctlAllocSpace },
@ -42,7 +42,24 @@ namespace Ryujinx.Core.OsHle.Services
{ ("/dev/nvmap", 0x010e), NvMapIocGetId }, { ("/dev/nvmap", 0x010e), NvMapIocGetId },
}; };
public static long NvDrvOpen(ServiceCtx Context) private Dictionary<int, ServiceProcessRequest> m_Commands;
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public ServiceNvDrv()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 0, Open },
{ 1, Ioctl },
{ 2, Close },
{ 3, Initialize },
{ 4, QueryEvent },
{ 8, SetClientPid },
};
}
public static long Open(ServiceCtx Context)
{ {
long NamePtr = Context.Request.SendBuff[0].Position; long NamePtr = Context.Request.SendBuff[0].Position;
@ -56,7 +73,7 @@ namespace Ryujinx.Core.OsHle.Services
return 0; return 0;
} }
public static long NvDrvIoctl(ServiceCtx Context) public static long Ioctl(ServiceCtx Context)
{ {
int Fd = Context.RequestData.ReadInt32(); int Fd = Context.RequestData.ReadInt32();
int Cmd = Context.RequestData.ReadInt32() & 0xffff; int Cmd = Context.RequestData.ReadInt32() & 0xffff;
@ -67,7 +84,7 @@ namespace Ryujinx.Core.OsHle.Services
Context.ResponseData.Write(0); Context.ResponseData.Write(0);
if (IoctlCmds.TryGetValue((FdData.Name, Cmd), out ServiceProcessRequest ProcReq)) if (IoctlCmds.TryGetValue((FdData.Name, Cmd), out ServiceProcessIoctl ProcReq))
{ {
return ProcReq(Context); return ProcReq(Context);
} }
@ -77,7 +94,7 @@ namespace Ryujinx.Core.OsHle.Services
} }
} }
public static long NvDrvClose(ServiceCtx Context) public static long Close(ServiceCtx Context)
{ {
int Fd = Context.RequestData.ReadInt32(); int Fd = Context.RequestData.ReadInt32();
@ -88,7 +105,7 @@ namespace Ryujinx.Core.OsHle.Services
return 0; return 0;
} }
public static long NvDrvInitialize(ServiceCtx Context) public static long Initialize(ServiceCtx Context)
{ {
long TransferMemSize = Context.RequestData.ReadInt64(); long TransferMemSize = Context.RequestData.ReadInt64();
int TransferMemHandle = Context.Request.HandleDesc.ToCopy[0]; int TransferMemHandle = Context.Request.HandleDesc.ToCopy[0];
@ -98,7 +115,7 @@ namespace Ryujinx.Core.OsHle.Services
return 0; return 0;
} }
public static long NvDrvQueryEvent(ServiceCtx Context) public static long QueryEvent(ServiceCtx Context)
{ {
int Fd = Context.RequestData.ReadInt32(); int Fd = Context.RequestData.ReadInt32();
int EventId = Context.RequestData.ReadInt32(); int EventId = Context.RequestData.ReadInt32();
@ -110,7 +127,7 @@ namespace Ryujinx.Core.OsHle.Services
return 0; return 0;
} }
public static long NvDrvSetClientPid(ServiceCtx Context) public static long SetClientPid(ServiceCtx Context)
{ {
long Pid = Context.RequestData.ReadInt64(); long Pid = Context.RequestData.ReadInt64();

View file

@ -1,7 +1,7 @@
using Ryujinx.Core.OsHle.Handles; using Ryujinx.Core.OsHle.Handles;
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
namespace Ryujinx.Core.OsHle.Objects namespace Ryujinx.Core.OsHle.IpcServices
{ {
static class ObjHelper static class ObjHelper
{ {

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Am namespace Ryujinx.Core.OsHle.IpcServices.Pctl
{ {
class IParentalControlService : IIpcInterface class IParentalControlService : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -0,0 +1,29 @@
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
namespace Ryujinx.Core.OsHle.IpcServices.Pctl
{
class ServicePctl : IIpcService
{
private Dictionary<int, ServiceProcessRequest> m_Commands;
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public ServicePctl()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 0, CreateService }
};
}
public static long CreateService(ServiceCtx Context)
{
MakeObject(Context, new IParentalControlService());
return 0;
}
}
}

View file

@ -0,0 +1,51 @@
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.IpcServices.Pl
{
class ServicePl : IIpcService
{
private Dictionary<int, ServiceProcessRequest> m_Commands;
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public ServicePl()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 1, GetLoadState },
{ 2, GetFontSize },
{ 3, GetSharedMemoryAddressOffset },
{ 4, GetSharedMemoryNativeHandle }
};
}
public static long GetLoadState(ServiceCtx Context)
{
Context.ResponseData.Write(1); //Loaded
return 0;
}
public static long GetFontSize(ServiceCtx Context)
{
Context.ResponseData.Write(Horizon.FontSize);
return 0;
}
public static long GetSharedMemoryAddressOffset(ServiceCtx Context)
{
Context.ResponseData.Write(0);
return 0;
}
public static long GetSharedMemoryNativeHandle(ServiceCtx Context)
{
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Context.Ns.Os.FontHandle);
return 0;
}
}
}

View file

@ -0,0 +1,50 @@
using Ryujinx.Core.OsHle.IpcServices.Acc;
using Ryujinx.Core.OsHle.IpcServices.Am;
using Ryujinx.Core.OsHle.IpcServices.Apm;
using Ryujinx.Core.OsHle.IpcServices.Aud;
using Ryujinx.Core.OsHle.IpcServices.Friend;
using Ryujinx.Core.OsHle.IpcServices.FspSrv;
using Ryujinx.Core.OsHle.IpcServices.Hid;
using Ryujinx.Core.OsHle.IpcServices.Lm;
using Ryujinx.Core.OsHle.IpcServices.NvServices;
using Ryujinx.Core.OsHle.IpcServices.Pctl;
using Ryujinx.Core.OsHle.IpcServices.Pl;
using Ryujinx.Core.OsHle.IpcServices.Set;
using Ryujinx.Core.OsHle.IpcServices.Sm;
using Ryujinx.Core.OsHle.IpcServices.Time;
using Ryujinx.Core.OsHle.IpcServices.Vi;
using System;
namespace Ryujinx.Core.OsHle.IpcServices
{
static class ServiceFactory
{
public static IIpcService MakeService(string Name)
{
switch (Name)
{
case "acc:u0": return new ServiceAcc();
case "apm": return new ServiceApm();
case "apm:p": return new ServiceApm();
case "appletOE": return new ServiceAppletOE();
case "audout:u": return new ServiceAudOut();
case "audren:u": return new ServiceAudRen();
case "friend:a": return new ServiceFriend();
case "fsp-srv": return new ServiceFspSrv();
case "hid": return new ServiceHid();
case "lm": return new ServiceLm();
case "nvdrv": return new ServiceNvDrv();
case "nvdrv:a": return new ServiceNvDrv();
case "pctl:a": return new ServicePctl();
case "pl:u": return new ServicePl();
case "set": return new ServiceSet();
case "sm:": return new ServiceSm();
case "time:s": return new ServiceTime();
case "time:u": return new ServiceTime();
case "vi:m": return new ServiceVi();
}
throw new NotImplementedException(Name);
}
}
}

View file

@ -1,12 +1,26 @@
using ChocolArm64.Memory; using ChocolArm64.Memory;
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Services namespace Ryujinx.Core.OsHle.IpcServices.Set
{ {
static partial class Service class ServiceSet : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands;
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public ServiceSet()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 1, GetAvailableLanguageCodes }
};
}
private const int LangCodesCount = 13; private const int LangCodesCount = 13;
public static long SetGetAvailableLanguageCodes(ServiceCtx Context) public static long GetAvailableLanguageCodes(ServiceCtx Context)
{ {
int PtrBuffSize = Context.RequestData.ReadInt32(); int PtrBuffSize = Context.RequestData.ReadInt32();

View file

@ -1,20 +1,34 @@
using Ryujinx.Core.OsHle.Handles; using Ryujinx.Core.OsHle.Handles;
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Services namespace Ryujinx.Core.OsHle.IpcServices.Sm
{ {
static partial class Service class ServiceSm : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands;
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public ServiceSm()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 0, Initialize },
{ 1, GetService }
};
}
private const int SmNotInitialized = 0x415; private const int SmNotInitialized = 0x415;
public static long SmInitialize(ServiceCtx Context) public long Initialize(ServiceCtx Context)
{ {
Context.Session.Initialize(); Context.Session.Initialize();
return 0; return 0;
} }
public static long SmGetService(ServiceCtx Context) public long GetService(ServiceCtx Context)
{ {
//Only for kernel version > 3.0.0. //Only for kernel version > 3.0.0.
if (!Context.Session.IsInitialized) if (!Context.Session.IsInitialized)
@ -36,7 +50,12 @@ namespace Ryujinx.Core.OsHle.Services
} }
} }
HSession Session = new HSession(Name); if (Name == string.Empty)
{
return 0;
}
HSession Session = new HSession(ServiceFactory.MakeService(Name));
int Handle = Context.Ns.Os.Handles.GenerateId(Session); int Handle = Context.Ns.Os.Handles.GenerateId(Session);

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Time namespace Ryujinx.Core.OsHle.IpcServices.Time
{ {
class ISteadyClock : IIpcInterface class ISteadyClock : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -2,9 +2,9 @@ using Ryujinx.Core.OsHle.Ipc;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Time namespace Ryujinx.Core.OsHle.IpcServices.Time
{ {
class ISystemClock : IIpcInterface class ISystemClock : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Time namespace Ryujinx.Core.OsHle.IpcServices.Time
{ {
class ITimeZoneService : IIpcInterface class ITimeZoneService : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -0,0 +1,62 @@
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
namespace Ryujinx.Core.OsHle.IpcServices.Time
{
class ServiceTime : IIpcService
{
private Dictionary<int, ServiceProcessRequest> m_Commands;
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public ServiceTime()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 0, GetStandardUserSystemClock },
{ 1, GetStandardNetworkSystemClock },
{ 2, GetStandardSteadyClock },
{ 3, GetTimeZoneService },
{ 4, GetStandardLocalSystemClock }
};
}
public long GetStandardUserSystemClock(ServiceCtx Context)
{
MakeObject(Context, new ISystemClock(SystemClockType.User));
return 0;
}
public long GetStandardNetworkSystemClock(ServiceCtx Context)
{
MakeObject(Context, new ISystemClock(SystemClockType.Network));
return 0;
}
public long GetStandardSteadyClock(ServiceCtx Context)
{
MakeObject(Context, new ISteadyClock());
return 0;
}
public long GetTimeZoneService(ServiceCtx Context)
{
MakeObject(Context, new ITimeZoneService());
return 0;
}
public long GetStandardLocalSystemClock(ServiceCtx Context)
{
MakeObject(Context, new ISystemClock(SystemClockType.Local));
return 0;
}
}
}

View file

@ -1,4 +1,4 @@
namespace Ryujinx.Core.OsHle.Objects.Time namespace Ryujinx.Core.OsHle.IpcServices.Time
{ {
enum SystemClockType enum SystemClockType
{ {

View file

@ -4,12 +4,12 @@ using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using static Ryujinx.Core.OsHle.Objects.Android.Parcel; using static Ryujinx.Core.OsHle.IpcServices.Android.Parcel;
using static Ryujinx.Core.OsHle.Objects.ObjHelper; using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
namespace Ryujinx.Core.OsHle.Objects.Vi namespace Ryujinx.Core.OsHle.IpcServices.Vi
{ {
class IApplicationDisplayService : IIpcInterface class IApplicationDisplayService : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -1,12 +1,12 @@
using ChocolArm64.Memory; using ChocolArm64.Memory;
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using Ryujinx.Core.OsHle.Objects.Android; using Ryujinx.Core.OsHle.IpcServices.Android;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Vi namespace Ryujinx.Core.OsHle.IpcServices.Vi
{ {
class IHOSBinderDriver : IIpcInterface, IDisposable class IHOSBinderDriver : IIpcService, IDisposable
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Vi namespace Ryujinx.Core.OsHle.IpcServices.Vi
{ {
class IManagerDisplayService : IIpcInterface class IManagerDisplayService : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -1,9 +1,9 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Objects.Vi namespace Ryujinx.Core.OsHle.IpcServices.Vi
{ {
class ISystemDisplayService : IIpcInterface class ISystemDisplayService : IIpcService
{ {
private Dictionary<int, ServiceProcessRequest> m_Commands; private Dictionary<int, ServiceProcessRequest> m_Commands;

View file

@ -0,0 +1,31 @@
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
namespace Ryujinx.Core.OsHle.IpcServices.Vi
{
class ServiceVi : IIpcService
{
private Dictionary<int, ServiceProcessRequest> m_Commands;
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public ServiceVi()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 2, GetDisplayService }
};
}
public long GetDisplayService(ServiceCtx Context)
{
int Unknown = Context.RequestData.ReadInt32();
MakeObject(Context, new IApplicationDisplayService());
return 0;
}
}
}

View file

@ -1,33 +0,0 @@
using Ryujinx.Core.OsHle.Objects.Acc;
using static Ryujinx.Core.OsHle.Objects.ObjHelper;
namespace Ryujinx.Core.OsHle.Services
{
static partial class Service
{
public static long AccU0ListOpenUsers(ServiceCtx Context)
{
return 0;
}
public static long AccU0GetProfile(ServiceCtx Context)
{
MakeObject(Context, new IProfile());
return 0;
}
public static long AccU0InitializeApplicationInfo(ServiceCtx Context)
{
return 0;
}
public static long AccU0GetBaasAccountManagerForApplication(ServiceCtx Context)
{
MakeObject(Context, new IManagerForApplication());
return 0;
}
}
}

View file

@ -1,16 +0,0 @@
using Ryujinx.Core.OsHle.Objects.Apm;
using static Ryujinx.Core.OsHle.Objects.ObjHelper;
namespace Ryujinx.Core.OsHle.Services
{
static partial class Service
{
public static long ApmOpenSession(ServiceCtx Context)
{
MakeObject(Context, new ISession());
return 0;
}
}
}

View file

@ -1,16 +0,0 @@
using Ryujinx.Core.OsHle.Objects.Am;
using static Ryujinx.Core.OsHle.Objects.ObjHelper;
namespace Ryujinx.Core.OsHle.Services
{
static partial class Service
{
public static long AppletOpenApplicationProxy(ServiceCtx Context)
{
MakeObject(Context, new IApplicationProxy());
return 0;
}
}
}

View file

@ -1,71 +0,0 @@
using ChocolArm64.Memory;
using Ryujinx.Core.OsHle.Objects.Aud;
using System.Text;
using static Ryujinx.Core.OsHle.Objects.ObjHelper;
namespace Ryujinx.Core.OsHle.Services
{
static partial class Service
{
public static long AudOutListAudioOuts(ServiceCtx Context)
{
long Position = Context.Request.ReceiveBuff[0].Position;
AMemoryHelper.WriteBytes(Context.Memory, Position, Encoding.ASCII.GetBytes("iface"));
Context.ResponseData.Write(1);
return 0;
}
public static long AudOutOpenAudioOut(ServiceCtx Context)
{
MakeObject(Context, new IAudioOut());
Context.ResponseData.Write(48000); //Sample Rate
Context.ResponseData.Write(2); //Channel Count
Context.ResponseData.Write(2); //PCM Format
/*
0 - Invalid
1 - INT8
2 - INT16
3 - INT24
4 - INT32
5 - PCM Float
6 - ADPCM
*/
Context.ResponseData.Write(0); //Unknown
return 0;
}
public static long AudRenOpenAudioRenderer(ServiceCtx Context)
{
MakeObject(Context, new IAudioRenderer());
return 0;
}
public static long AudRenGetAudioRendererWorkBufferSize(ServiceCtx Context)
{
int SampleRate = Context.RequestData.ReadInt32();
int Unknown4 = Context.RequestData.ReadInt32();
int Unknown8 = Context.RequestData.ReadInt32();
int UnknownC = Context.RequestData.ReadInt32();
int Unknown10 = Context.RequestData.ReadInt32();
int Unknown14 = Context.RequestData.ReadInt32();
int Unknown18 = Context.RequestData.ReadInt32();
int Unknown1c = Context.RequestData.ReadInt32();
int Unknown20 = Context.RequestData.ReadInt32();
int Unknown24 = Context.RequestData.ReadInt32();
int Unknown28 = Context.RequestData.ReadInt32();
int Unknown2c = Context.RequestData.ReadInt32();
int Rev1Magic = Context.RequestData.ReadInt32();
Context.ResponseData.Write(0x400L);
return 0;
}
}
}

View file

@ -1,16 +0,0 @@
using Ryujinx.Core.OsHle.Objects.Friend;
using static Ryujinx.Core.OsHle.Objects.ObjHelper;
namespace Ryujinx.Core.OsHle.Services
{
static partial class Service
{
public static long FriendCreateFriendService(ServiceCtx Context)
{
MakeObject(Context, new IFriendService());
return 0;
}
}
}

View file

@ -1,49 +0,0 @@
using Ryujinx.Core.OsHle.Objects.FspSrv;
using static Ryujinx.Core.OsHle.Objects.ObjHelper;
namespace Ryujinx.Core.OsHle.Services
{
static partial class Service
{
public static long FspSrvInitialize(ServiceCtx Context)
{
return 0;
}
public static long FspSrvMountSdCard(ServiceCtx Context)
{
MakeObject(Context, new IFileSystem(Context.Ns.VFs.GetSdCardPath()));
return 0;
}
public static long FspSrvMountSaveData(ServiceCtx Context)
{
MakeObject(Context, new IFileSystem(Context.Ns.VFs.GetGameSavesPath()));
return 0;
}
public static long FspSrvOpenDataStorageByCurrentProcess(ServiceCtx Context)
{
MakeObject(Context, new IStorage(Context.Ns.VFs.RomFs));
return 0;
}
public static long FspSrvOpenRomStorage(ServiceCtx Context)
{
MakeObject(Context, new IStorage(Context.Ns.VFs.RomFs));
return 0;
}
public static long FspSrvGetGlobalAccessLogMode(ServiceCtx Context)
{
Context.ResponseData.Write(0);
return 0;
}
}
}

View file

@ -1,77 +0,0 @@
using Ryujinx.Core.OsHle.Handles;
using Ryujinx.Core.OsHle.Objects.Hid;
using static Ryujinx.Core.OsHle.Objects.ObjHelper;
namespace Ryujinx.Core.OsHle.Services
{
static partial class Service
{
public static long HidCreateAppletResource(ServiceCtx Context)
{
HSharedMem HidHndData = Context.Ns.Os.Handles.GetData<HSharedMem>(Context.Ns.Os.HidHandle);
MakeObject(Context, new IAppletResource(HidHndData));
return 0;
}
public static long HidActivateTouchScreen(ServiceCtx Context)
{
long Unknown = Context.RequestData.ReadInt64();
return 0;
}
public static long HidGetSupportedNpadStyleSet(ServiceCtx Context)
{
Context.ResponseData.Write(0);
return 0;
}
public static long HidSetSupportedNpadStyleSet(ServiceCtx Context)
{
long Unknown0 = Context.RequestData.ReadInt64();
long Unknown8 = Context.RequestData.ReadInt64();
return 0;
}
public static long HidSetSupportedNpadIdType(ServiceCtx Context)
{
long Unknown = Context.RequestData.ReadInt64();
return 0;
}
public static long HidActivateNpad(ServiceCtx Context)
{
long Unknown = Context.RequestData.ReadInt64();
return 0;
}
public static long HidSetNpadJoyHoldType(ServiceCtx Context)
{
long Unknown0 = Context.RequestData.ReadInt64();
long Unknown8 = Context.RequestData.ReadInt64();
return 0;
}
public static long HidGetNpadJoyHoldType(ServiceCtx Context)
{
Context.ResponseData.Write(0L);
return 0;
}
public static long HidCreateActiveVibrationDeviceList(ServiceCtx Context)
{
MakeObject(Context, new IActiveApplicationDeviceList());
return 0;
}
}
}

View file

@ -1,12 +0,0 @@
namespace Ryujinx.Core.OsHle.Services
{
static partial class Service
{
public static long LmInitialize(ServiceCtx Context)
{
Context.Session.Initialize();
return 0;
}
}
}

View file

@ -1,16 +0,0 @@
using Ryujinx.Core.OsHle.Objects.Am;
using static Ryujinx.Core.OsHle.Objects.ObjHelper;
namespace Ryujinx.Core.OsHle.Services
{
static partial class Service
{
public static long PctlCreateService(ServiceCtx Context)
{
MakeObject(Context, new IParentalControlService());
return 0;
}
}
}

View file

@ -1,35 +0,0 @@
using Ryujinx.Core.OsHle.Ipc;
namespace Ryujinx.Core.OsHle.Services
{
static partial class Service
{
public static long PlGetLoadState(ServiceCtx Context)
{
Context.ResponseData.Write(1); //Loaded
return 0;
}
public static long PlGetFontSize(ServiceCtx Context)
{
Context.ResponseData.Write(Horizon.FontSize);
return 0;
}
public static long PlGetSharedMemoryAddressOffset(ServiceCtx Context)
{
Context.ResponseData.Write(0);
return 0;
}
public static long PlGetSharedMemoryNativeHandle(ServiceCtx Context)
{
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Context.Ns.Os.FontHandle);
return 0;
}
}
}

View file

@ -1,45 +0,0 @@
using Ryujinx.Core.OsHle.Objects.Time;
using static Ryujinx.Core.OsHle.Objects.ObjHelper;
namespace Ryujinx.Core.OsHle.Services
{
static partial class Service
{
public static long TimeGetStandardUserSystemClock(ServiceCtx Context)
{
MakeObject(Context, new ISystemClock(SystemClockType.User));
return 0;
}
public static long TimeGetStandardNetworkSystemClock(ServiceCtx Context)
{
MakeObject(Context, new ISystemClock(SystemClockType.Network));
return 0;
}
public static long TimeGetStandardSteadyClock(ServiceCtx Context)
{
MakeObject(Context, new ISteadyClock());
return 0;
}
public static long TimeGetTimeZoneService(ServiceCtx Context)
{
MakeObject(Context, new ITimeZoneService());
return 0;
}
public static long TimeGetStandardLocalSystemClock(ServiceCtx Context)
{
MakeObject(Context, new ISystemClock(SystemClockType.Local));
return 0;
}
}
}

View file

@ -1,18 +0,0 @@
using Ryujinx.Core.OsHle.Objects.Vi;
using static Ryujinx.Core.OsHle.Objects.ObjHelper;
namespace Ryujinx.Core.OsHle.Services
{
static partial class Service
{
public static long ViGetDisplayService(ServiceCtx Context)
{
int Unknown = Context.RequestData.ReadInt32();
MakeObject(Context, new IApplicationDisplayService());
return 0;
}
}
}

View file

@ -3,6 +3,7 @@ using ChocolArm64.State;
using Ryujinx.Core.OsHle.Exceptions; using Ryujinx.Core.OsHle.Exceptions;
using Ryujinx.Core.OsHle.Handles; using Ryujinx.Core.OsHle.Handles;
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using Ryujinx.Core.OsHle.IpcServices;
using System; using System;
using System.Threading; using System.Threading;
@ -61,7 +62,7 @@ namespace Ryujinx.Core.OsHle.Svc
//TODO: Validate that app has perms to access the service, and that the service //TODO: Validate that app has perms to access the service, and that the service
//actually exists, return error codes otherwise. //actually exists, return error codes otherwise.
HSession Session = new HSession(Name); HSession Session = new HSession(ServiceFactory.MakeService(Name));
ThreadState.X1 = (ulong)Ns.Os.Handles.GenerateId(Session); ThreadState.X1 = (ulong)Ns.Os.Handles.GenerateId(Session);
ThreadState.X0 = (int)SvcResult.Success; ThreadState.X0 = (int)SvcResult.Success;