Merge branch 'master' into ICommonStateGetter
This commit is contained in:
commit
c636c74dd2
248 changed files with 2266 additions and 2244 deletions
7
Ryujinx.HLE/OsHle/Services/Am/AmErr.cs
Normal file
7
Ryujinx.HLE/OsHle/Services/Am/AmErr.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
static class AmErr
|
||||
{
|
||||
public const int NoMessages = 3;
|
||||
}
|
||||
}
|
8
Ryujinx.HLE/OsHle/Services/Am/FocusState.cs
Normal file
8
Ryujinx.HLE/OsHle/Services/Am/FocusState.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
enum FocusState
|
||||
{
|
||||
InFocus = 1,
|
||||
OutOfFocus = 2
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class IAllSystemAppletProxiesService : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IAllSystemAppletProxiesService()
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 100, OpenSystemAppletProxy }
|
||||
};
|
||||
}
|
||||
|
||||
public long OpenSystemAppletProxy(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new ISystemAppletProxy());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
20
Ryujinx.HLE/OsHle/Services/Am/IApplicationCreator.cs
Normal file
20
Ryujinx.HLE/OsHle/Services/Am/IApplicationCreator.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class IApplicationCreator : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IApplicationCreator()
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
//...
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
117
Ryujinx.HLE/OsHle/Services/Am/IApplicationFunctions.cs
Normal file
117
Ryujinx.HLE/OsHle/Services/Am/IApplicationFunctions.cs
Normal file
|
@ -0,0 +1,117 @@
|
|||
using Ryujinx.HLE.Logging;
|
||||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class IApplicationFunctions : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IApplicationFunctions()
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 1, PopLaunchParameter },
|
||||
{ 20, EnsureSaveData },
|
||||
{ 21, GetDesiredLanguage },
|
||||
{ 22, SetTerminateResult },
|
||||
{ 23, GetDisplayVersion },
|
||||
{ 40, NotifyRunning },
|
||||
{ 50, GetPseudoDeviceId },
|
||||
{ 66, InitializeGamePlayRecording },
|
||||
{ 67, SetGamePlayRecordingState }
|
||||
};
|
||||
}
|
||||
|
||||
public long PopLaunchParameter(ServiceCtx Context)
|
||||
{
|
||||
//Only the first 0x18 bytes of the Data seems to be actually used.
|
||||
MakeObject(Context, new IStorage(StorageHelper.MakeLaunchParams()));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long EnsureSaveData(ServiceCtx Context)
|
||||
{
|
||||
long UIdLow = Context.RequestData.ReadInt64();
|
||||
long UIdHigh = Context.RequestData.ReadInt64();
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
Context.ResponseData.Write(0L);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetDesiredLanguage(ServiceCtx Context)
|
||||
{
|
||||
Context.ResponseData.Write(Context.Ns.Os.SystemState.DesiredLanguageCode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long SetTerminateResult(ServiceCtx Context)
|
||||
{
|
||||
int ErrorCode = Context.RequestData.ReadInt32();
|
||||
|
||||
string Result = GetFormattedErrorCode(ErrorCode);
|
||||
|
||||
Context.Ns.Log.PrintInfo(LogClass.ServiceAm, $"Result = 0x{ErrorCode:x8} ({Result}).");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private string GetFormattedErrorCode(int ErrorCode)
|
||||
{
|
||||
int Module = (ErrorCode >> 0) & 0x1ff;
|
||||
int Description = (ErrorCode >> 9) & 0x1fff;
|
||||
|
||||
return $"{(2000 + Module):d4}-{Description:d4}";
|
||||
}
|
||||
|
||||
public long GetDisplayVersion(ServiceCtx Context)
|
||||
{
|
||||
//FIXME: Need to check correct version on a switch.
|
||||
Context.ResponseData.Write(1L);
|
||||
Context.ResponseData.Write(0L);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long NotifyRunning(ServiceCtx Context)
|
||||
{
|
||||
Context.ResponseData.Write(1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetPseudoDeviceId(ServiceCtx Context)
|
||||
{
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
Context.ResponseData.Write(0L);
|
||||
Context.ResponseData.Write(0L);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long InitializeGamePlayRecording(ServiceCtx Context)
|
||||
{
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long SetGamePlayRecordingState(ServiceCtx Context)
|
||||
{
|
||||
int State = Context.RequestData.ReadInt32();
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
83
Ryujinx.HLE/OsHle/Services/Am/IApplicationProxy.cs
Normal file
83
Ryujinx.HLE/OsHle/Services/Am/IApplicationProxy.cs
Normal file
|
@ -0,0 +1,83 @@
|
|||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class IApplicationProxy : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IApplicationProxy()
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 0, GetCommonStateGetter },
|
||||
{ 1, GetSelfController },
|
||||
{ 2, GetWindowController },
|
||||
{ 3, GetAudioController },
|
||||
{ 4, GetDisplayController },
|
||||
{ 11, GetLibraryAppletCreator },
|
||||
{ 20, GetApplicationFunctions },
|
||||
{ 1000, GetDebugFunctions }
|
||||
};
|
||||
}
|
||||
|
||||
public long GetCommonStateGetter(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new ICommonStateGetter());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetSelfController(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new ISelfController());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetWindowController(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new IWindowController());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetAudioController(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new IAudioController());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetDisplayController(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new IDisplayController());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetLibraryAppletCreator(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new ILibraryAppletCreator());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetApplicationFunctions(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new IApplicationFunctions());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetDebugFunctions(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new IDebugFunctions());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
27
Ryujinx.HLE/OsHle/Services/Am/IApplicationProxyService.cs
Normal file
27
Ryujinx.HLE/OsHle/Services/Am/IApplicationProxyService.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class IApplicationProxyService : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IApplicationProxyService()
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 0, OpenApplicationProxy }
|
||||
};
|
||||
}
|
||||
|
||||
public long OpenApplicationProxy(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new IApplicationProxy());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
72
Ryujinx.HLE/OsHle/Services/Am/IAudioController.cs
Normal file
72
Ryujinx.HLE/OsHle/Services/Am/IAudioController.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
using Ryujinx.HLE.Logging;
|
||||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class IAudioController : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IAudioController()
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 0, SetExpectedMasterVolume },
|
||||
{ 1, GetMainAppletExpectedMasterVolume },
|
||||
{ 2, GetLibraryAppletExpectedMasterVolume },
|
||||
{ 3, ChangeMainAppletMasterVolume },
|
||||
{ 4, SetTransparentVolumeRate }
|
||||
};
|
||||
}
|
||||
|
||||
public long SetExpectedMasterVolume(ServiceCtx Context)
|
||||
{
|
||||
float AppletVolume = Context.RequestData.ReadSingle();
|
||||
float LibraryAppletVolume = Context.RequestData.ReadSingle();
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetMainAppletExpectedMasterVolume(ServiceCtx Context)
|
||||
{
|
||||
Context.ResponseData.Write(1f);
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetLibraryAppletExpectedMasterVolume(ServiceCtx Context)
|
||||
{
|
||||
Context.ResponseData.Write(1f);
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long ChangeMainAppletMasterVolume(ServiceCtx Context)
|
||||
{
|
||||
float Unknown0 = Context.RequestData.ReadSingle();
|
||||
long Unknown1 = Context.RequestData.ReadInt64();
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long SetTransparentVolumeRate(ServiceCtx Context)
|
||||
{
|
||||
float Unknown0 = Context.RequestData.ReadSingle();
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
109
Ryujinx.HLE/OsHle/Services/Am/ICommonStateGetter.cs
Normal file
109
Ryujinx.HLE/OsHle/Services/Am/ICommonStateGetter.cs
Normal file
|
@ -0,0 +1,109 @@
|
|||
using Ryujinx.HLE.Logging;
|
||||
using Ryujinx.HLE.OsHle.Handles;
|
||||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using static Ryujinx.HLE.OsHle.ErrorCode;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class ICommonStateGetter : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
private KEvent DisplayResolutionChangeEvent;
|
||||
|
||||
public ICommonStateGetter()
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 0, GetEventHandle },
|
||||
{ 1, ReceiveMessage },
|
||||
{ 5, GetOperationMode },
|
||||
{ 6, GetPerformanceMode },
|
||||
{ 8, GetBootMode },
|
||||
{ 9, GetCurrentFocusState },
|
||||
{ 60, GetDefaultDisplayResolution },
|
||||
{ 61, GetDefaultDisplayResolutionChangeEvent }
|
||||
};
|
||||
|
||||
DisplayResolutionChangeEvent = new KEvent();
|
||||
}
|
||||
|
||||
public long GetEventHandle(ServiceCtx Context)
|
||||
{
|
||||
KEvent Event = Context.Process.AppletState.MessageEvent;
|
||||
|
||||
int Handle = Context.Process.HandleTable.OpenHandle(Event);
|
||||
|
||||
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long ReceiveMessage(ServiceCtx Context)
|
||||
{
|
||||
if (!Context.Process.AppletState.TryDequeueMessage(out MessageInfo Message))
|
||||
{
|
||||
return MakeError(ErrorModule.Am, AmErr.NoMessages);
|
||||
}
|
||||
|
||||
Context.ResponseData.Write((int)Message);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetOperationMode(ServiceCtx Context)
|
||||
{
|
||||
Context.ResponseData.Write((byte)OperationMode.Handheld);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetPerformanceMode(ServiceCtx Context)
|
||||
{
|
||||
Context.ResponseData.Write((byte)Apm.PerformanceMode.Handheld);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetBootMode(ServiceCtx Context)
|
||||
{
|
||||
Context.ResponseData.Write((byte)0); //Unknown value.
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetCurrentFocusState(ServiceCtx Context)
|
||||
{
|
||||
Context.ResponseData.Write((byte)Context.Process.AppletState.FocusState);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetDefaultDisplayResolution(ServiceCtx Context)
|
||||
{
|
||||
Context.ResponseData.Write(1280);
|
||||
Context.ResponseData.Write(720);
|
||||
|
||||
// Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetDefaultDisplayResolutionChangeEvent(ServiceCtx Context)
|
||||
{
|
||||
int Handle = Context.Process.HandleTable.OpenHandle(DisplayResolutionChangeEvent);
|
||||
|
||||
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
20
Ryujinx.HLE/OsHle/Services/Am/IDebugFunctions.cs
Normal file
20
Ryujinx.HLE/OsHle/Services/Am/IDebugFunctions.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class IDebugFunctions : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IDebugFunctions()
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
//...
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
20
Ryujinx.HLE/OsHle/Services/Am/IDisplayController.cs
Normal file
20
Ryujinx.HLE/OsHle/Services/Am/IDisplayController.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class IDisplayController : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IDisplayController()
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
//...
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
20
Ryujinx.HLE/OsHle/Services/Am/IGlobalStateController.cs
Normal file
20
Ryujinx.HLE/OsHle/Services/Am/IGlobalStateController.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class IGlobalStateController : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IGlobalStateController()
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
//...
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
46
Ryujinx.HLE/OsHle/Services/Am/IHomeMenuFunctions.cs
Normal file
46
Ryujinx.HLE/OsHle/Services/Am/IHomeMenuFunctions.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
using Ryujinx.HLE.Logging;
|
||||
using Ryujinx.HLE.OsHle.Handles;
|
||||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class IHomeMenuFunctions : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
private KEvent ChannelEvent;
|
||||
|
||||
public IHomeMenuFunctions()
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 10, RequestToGetForeground },
|
||||
{ 21, GetPopFromGeneralChannelEvent }
|
||||
};
|
||||
|
||||
//ToDo: Signal this Event somewhere in future.
|
||||
ChannelEvent = new KEvent();
|
||||
}
|
||||
|
||||
public long RequestToGetForeground(ServiceCtx Context)
|
||||
{
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetPopFromGeneralChannelEvent(ServiceCtx Context)
|
||||
{
|
||||
int Handle = Context.Process.HandleTable.OpenHandle(ChannelEvent);
|
||||
|
||||
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
71
Ryujinx.HLE/OsHle/Services/Am/ILibraryAppletAccessor.cs
Normal file
71
Ryujinx.HLE/OsHle/Services/Am/ILibraryAppletAccessor.cs
Normal file
|
@ -0,0 +1,71 @@
|
|||
using Ryujinx.HLE.Logging;
|
||||
using Ryujinx.HLE.OsHle.Handles;
|
||||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class ILibraryAppletAccessor : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
private KEvent StateChangedEvent;
|
||||
|
||||
public ILibraryAppletAccessor()
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 0, GetAppletStateChangedEvent },
|
||||
{ 10, Start },
|
||||
{ 30, GetResult },
|
||||
{ 100, PushInData },
|
||||
{ 101, PopOutData }
|
||||
};
|
||||
|
||||
StateChangedEvent = new KEvent();
|
||||
}
|
||||
|
||||
public long GetAppletStateChangedEvent(ServiceCtx Context)
|
||||
{
|
||||
StateChangedEvent.WaitEvent.Set();
|
||||
|
||||
int Handle = Context.Process.HandleTable.OpenHandle(StateChangedEvent);
|
||||
|
||||
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long Start(ServiceCtx Context)
|
||||
{
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetResult(ServiceCtx Context)
|
||||
{
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long PushInData(ServiceCtx Context)
|
||||
{
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long PopOutData(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new IStorage(StorageHelper.MakeLaunchParams()));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
37
Ryujinx.HLE/OsHle/Services/Am/ILibraryAppletCreator.cs
Normal file
37
Ryujinx.HLE/OsHle/Services/Am/ILibraryAppletCreator.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class ILibraryAppletCreator : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public ILibraryAppletCreator()
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 0, CreateLibraryApplet },
|
||||
{ 10, CreateStorage }
|
||||
};
|
||||
}
|
||||
|
||||
public long CreateLibraryApplet(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new ILibraryAppletAccessor());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long CreateStorage(ServiceCtx Context)
|
||||
{
|
||||
long Size = Context.RequestData.ReadInt64();
|
||||
|
||||
MakeObject(Context, new IStorage(new byte[Size]));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
117
Ryujinx.HLE/OsHle/Services/Am/ISelfController.cs
Normal file
117
Ryujinx.HLE/OsHle/Services/Am/ISelfController.cs
Normal file
|
@ -0,0 +1,117 @@
|
|||
using Ryujinx.HLE.Logging;
|
||||
using Ryujinx.HLE.OsHle.Handles;
|
||||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class ISelfController : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
private KEvent LaunchableEvent;
|
||||
|
||||
public ISelfController()
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 1, LockExit },
|
||||
{ 9, GetLibraryAppletLaunchableEvent },
|
||||
{ 10, SetScreenShotPermission },
|
||||
{ 11, SetOperationModeChangedNotification },
|
||||
{ 12, SetPerformanceModeChangedNotification },
|
||||
{ 13, SetFocusHandlingMode },
|
||||
{ 14, SetRestartMessageEnabled },
|
||||
{ 16, SetOutOfFocusSuspendingEnabled },
|
||||
{ 50, SetHandlesRequestToDisplay }
|
||||
};
|
||||
|
||||
LaunchableEvent = new KEvent();
|
||||
}
|
||||
|
||||
public long LockExit(ServiceCtx Context)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetLibraryAppletLaunchableEvent(ServiceCtx Context)
|
||||
{
|
||||
LaunchableEvent.WaitEvent.Set();
|
||||
|
||||
int Handle = Context.Process.HandleTable.OpenHandle(LaunchableEvent);
|
||||
|
||||
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long SetScreenShotPermission(ServiceCtx Context)
|
||||
{
|
||||
bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long SetOperationModeChangedNotification(ServiceCtx Context)
|
||||
{
|
||||
bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long SetPerformanceModeChangedNotification(ServiceCtx Context)
|
||||
{
|
||||
bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long SetFocusHandlingMode(ServiceCtx Context)
|
||||
{
|
||||
bool Flag1 = Context.RequestData.ReadByte() != 0 ? true : false;
|
||||
bool Flag2 = Context.RequestData.ReadByte() != 0 ? true : false;
|
||||
bool Flag3 = Context.RequestData.ReadByte() != 0 ? true : false;
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long SetRestartMessageEnabled(ServiceCtx Context)
|
||||
{
|
||||
bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long SetOutOfFocusSuspendingEnabled(ServiceCtx Context)
|
||||
{
|
||||
bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long SetHandlesRequestToDisplay(ServiceCtx Context)
|
||||
{
|
||||
bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
|
||||
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
31
Ryujinx.HLE/OsHle/Services/Am/IStorage.cs
Normal file
31
Ryujinx.HLE/OsHle/Services/Am/IStorage.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class IStorage : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public byte[] Data { get; private set; }
|
||||
|
||||
public IStorage(byte[] Data)
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 0, Open }
|
||||
};
|
||||
|
||||
this.Data = Data;
|
||||
}
|
||||
|
||||
public long Open(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new IStorageAccessor(this));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
83
Ryujinx.HLE/OsHle/Services/Am/IStorageAccessor.cs
Normal file
83
Ryujinx.HLE/OsHle/Services/Am/IStorageAccessor.cs
Normal file
|
@ -0,0 +1,83 @@
|
|||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class IStorageAccessor : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
private IStorage Storage;
|
||||
|
||||
public IStorageAccessor(IStorage Storage)
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 0, GetSize },
|
||||
{ 10, Write },
|
||||
{ 11, Read }
|
||||
};
|
||||
|
||||
this.Storage = Storage;
|
||||
}
|
||||
|
||||
public long GetSize(ServiceCtx Context)
|
||||
{
|
||||
Context.ResponseData.Write((long)Storage.Data.Length);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long Write(ServiceCtx Context)
|
||||
{
|
||||
//TODO: Error conditions.
|
||||
long WritePosition = Context.RequestData.ReadInt64();
|
||||
|
||||
(long Position, long Size) = Context.Request.GetBufferType0x21();
|
||||
|
||||
if (Size > 0)
|
||||
{
|
||||
long MaxSize = Storage.Data.Length - WritePosition;
|
||||
|
||||
if (Size > MaxSize)
|
||||
{
|
||||
Size = MaxSize;
|
||||
}
|
||||
|
||||
byte[] Data = Context.Memory.ReadBytes(Position, Size);
|
||||
|
||||
Buffer.BlockCopy(Data, 0, Storage.Data, (int)WritePosition, (int)Size);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long Read(ServiceCtx Context)
|
||||
{
|
||||
//TODO: Error conditions.
|
||||
long ReadPosition = Context.RequestData.ReadInt64();
|
||||
|
||||
(long Position, long Size) = Context.Request.GetBufferType0x22();
|
||||
|
||||
byte[] Data;
|
||||
|
||||
if (Storage.Data.Length > Size)
|
||||
{
|
||||
Data = new byte[Size];
|
||||
|
||||
Buffer.BlockCopy(Storage.Data, 0, Data, 0, (int)Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
Data = Storage.Data;
|
||||
}
|
||||
|
||||
Context.Memory.WriteBytes(Position, Data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
99
Ryujinx.HLE/OsHle/Services/Am/ISystemAppletProxy.cs
Normal file
99
Ryujinx.HLE/OsHle/Services/Am/ISystemAppletProxy.cs
Normal file
|
@ -0,0 +1,99 @@
|
|||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class ISystemAppletProxy : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public ISystemAppletProxy()
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 0, GetCommonStateGetter },
|
||||
{ 1, GetSelfController },
|
||||
{ 2, GetWindowController },
|
||||
{ 3, GetAudioController },
|
||||
{ 4, GetDisplayController },
|
||||
{ 11, GetLibraryAppletCreator },
|
||||
{ 20, GetHomeMenuFunctions },
|
||||
{ 21, GetGlobalStateController },
|
||||
{ 22, GetApplicationCreator },
|
||||
{ 1000, GetDebugFunctions }
|
||||
};
|
||||
}
|
||||
|
||||
public long GetCommonStateGetter(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new ICommonStateGetter());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetSelfController(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new ISelfController());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetWindowController(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new IWindowController());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetAudioController(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new IAudioController());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetDisplayController(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new IDisplayController());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetLibraryAppletCreator(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new ILibraryAppletCreator());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetHomeMenuFunctions(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new IHomeMenuFunctions());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetGlobalStateController(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new IGlobalStateController());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetApplicationCreator(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new IApplicationCreator());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetDebugFunctions(ServiceCtx Context)
|
||||
{
|
||||
MakeObject(Context, new IDebugFunctions());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
38
Ryujinx.HLE/OsHle/Services/Am/IWindowController.cs
Normal file
38
Ryujinx.HLE/OsHle/Services/Am/IWindowController.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using Ryujinx.HLE.Logging;
|
||||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class IWindowController : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IWindowController()
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 1, GetAppletResourceUserId },
|
||||
{ 10, AcquireForegroundRights }
|
||||
};
|
||||
}
|
||||
|
||||
public long GetAppletResourceUserId(ServiceCtx Context)
|
||||
{
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
Context.ResponseData.Write(0L);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long AcquireForegroundRights(ServiceCtx Context)
|
||||
{
|
||||
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
9
Ryujinx.HLE/OsHle/Services/Am/MessageInfo.cs
Normal file
9
Ryujinx.HLE/OsHle/Services/Am/MessageInfo.cs
Normal file
|
@ -0,0 +1,9 @@
|
|||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
enum MessageInfo
|
||||
{
|
||||
FocusStateChanged = 0xf,
|
||||
OperationModeChanged = 0x1e,
|
||||
PerformanceModeChanged = 0x1f
|
||||
}
|
||||
}
|
8
Ryujinx.HLE/OsHle/Services/Am/OperationMode.cs
Normal file
8
Ryujinx.HLE/OsHle/Services/Am/OperationMode.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
enum OperationMode
|
||||
{
|
||||
Handheld = 0,
|
||||
Docked = 1
|
||||
}
|
||||
}
|
27
Ryujinx.HLE/OsHle/Services/Am/StorageHelper.cs
Normal file
27
Ryujinx.HLE/OsHle/Services/Am/StorageHelper.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Am
|
||||
{
|
||||
class StorageHelper
|
||||
{
|
||||
private const uint LaunchParamsMagic = 0xc79497ca;
|
||||
|
||||
public static byte[] MakeLaunchParams()
|
||||
{
|
||||
//Size needs to be at least 0x88 bytes otherwise application errors.
|
||||
using (MemoryStream MS = new MemoryStream())
|
||||
{
|
||||
BinaryWriter Writer = new BinaryWriter(MS);
|
||||
|
||||
MS.SetLength(0x88);
|
||||
|
||||
Writer.Write(LaunchParamsMagic);
|
||||
Writer.Write(1); //IsAccountSelected? Only lower 8 bits actually used.
|
||||
Writer.Write(1L); //User Id Low (note: User Id needs to be != 0)
|
||||
Writer.Write(0L); //User Id High
|
||||
|
||||
return MS.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue