SMO stubs and implementations (#129)

* WIP SMO stubs and implementations

* fixes?

* Add StorageHelper

* Whoops

* Compliant with review.

* Remove unnecessary usings
This commit is contained in:
Starlet
2018-06-02 18:46:09 -04:00
committed by gdkchan
parent f03a43fa38
commit 250e2084f4
22 changed files with 449 additions and 109 deletions

View File

@@ -1,7 +1,6 @@
using Ryujinx.Core.Logging;
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
using System.IO;
namespace Ryujinx.Core.OsHle.Services.Am
{
@@ -15,22 +14,22 @@ namespace Ryujinx.Core.OsHle.Services.Am
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 1, PopLaunchParameter },
{ 20, EnsureSaveData },
{ 21, GetDesiredLanguage },
{ 22, SetTerminateResult },
{ 23, GetDisplayVersion },
{ 40, NotifyRunning },
{ 50, GetPseudoDeviceId }
{ 1, PopLaunchParameter },
{ 20, EnsureSaveData },
{ 21, GetDesiredLanguage },
{ 22, SetTerminateResult },
{ 23, GetDisplayVersion },
{ 40, NotifyRunning },
{ 50, GetPseudoDeviceId },
{ 66, InitializeGamePlayRecording },
{ 67, SetGamePlayRecordingState }
};
}
private const uint LaunchParamsMagic = 0xc79497ca;
public long PopLaunchParameter(ServiceCtx Context)
{
//Only the first 0x18 bytes of the Data seems to be actually used.
MakeObject(Context, new IStorage(MakeLaunchParams()));
MakeObject(Context, new IStorage(StorageHelper.MakeLaunchParams()));
return 0;
}
@@ -99,22 +98,20 @@ namespace Ryujinx.Core.OsHle.Services.Am
return 0;
}
private byte[] MakeLaunchParams()
public long InitializeGamePlayRecording(ServiceCtx Context)
{
//Size needs to be at least 0x88 bytes otherwise application errors.
using (MemoryStream MS = new MemoryStream())
{
BinaryWriter Writer = new BinaryWriter(MS);
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
MS.SetLength(0x88);
return 0;
}
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
public long SetGamePlayRecordingState(ServiceCtx Context)
{
int State = Context.RequestData.ReadInt32();
return MS.ToArray();
}
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
return 0;
}
}
}

View File

@@ -0,0 +1,71 @@
using Ryujinx.Core.Logging;
using Ryujinx.Core.OsHle.Handles;
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
namespace Ryujinx.Core.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;
}
}
}

View File

@@ -13,8 +13,23 @@ namespace Ryujinx.Core.OsHle.Services.Am
{
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)
{
MakeObject(Context, new IStorage(StorageHelper.MakeLaunchParams()));
return 0;
}
}
}

View File

@@ -1,4 +1,5 @@
using Ryujinx.Core.Logging;
using Ryujinx.Core.OsHle.Handles;
using Ryujinx.Core.OsHle.Ipc;
using System.Collections.Generic;
@@ -10,11 +11,14 @@ namespace Ryujinx.Core.OsHle.Services.Am
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 },
@@ -23,6 +27,8 @@ namespace Ryujinx.Core.OsHle.Services.Am
{ 16, SetOutOfFocusSuspendingEnabled },
{ 50, SetHandlesRequestToDisplay }
};
LaunchableEvent = new KEvent();
}
public long LockExit(ServiceCtx Context)
@@ -30,6 +36,19 @@ namespace Ryujinx.Core.OsHle.Services.Am
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;

View File

@@ -1,4 +1,5 @@
using ChocolArm64.Memory;
using Ryujinx.Core.Logging;
using Ryujinx.Core.OsHle.Ipc;
using System;
using System.Collections.Generic;
@@ -18,6 +19,7 @@ namespace Ryujinx.Core.OsHle.Services.Am
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 0, GetSize },
{ 10, Write },
{ 11, Read }
};
@@ -31,6 +33,13 @@ namespace Ryujinx.Core.OsHle.Services.Am
return 0;
}
public long Write(ServiceCtx Context)
{
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
return 0;
}
public long Read(ServiceCtx Context)
{
long ReadPosition = Context.RequestData.ReadInt64();

View File

@@ -0,0 +1,27 @@
using System.IO;
namespace Ryujinx.Core.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();
}
}
}
}