[WIP] Add support for events (#60)
* Add support for events, move concept of domains to IpcService * Support waiting for KThread, remove some test code, other tweaks * Use move handle on NIFM since I can't test that now, it's better to leave it how it was
This commit is contained in:
7
Ryujinx.Core/OsHle/Services/Am/AmErr.cs
Normal file
7
Ryujinx.Core/OsHle/Services/Am/AmErr.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
{
|
||||
static class AmErr
|
||||
{
|
||||
public const int NoMessages = 3;
|
||||
}
|
||||
}
|
||||
8
Ryujinx.Core/OsHle/Services/Am/FocusState.cs
Normal file
8
Ryujinx.Core/OsHle/Services/Am/FocusState.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
{
|
||||
enum FocusState
|
||||
{
|
||||
InFocus = 1,
|
||||
OutOfFocus = 2
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,13 @@ using Ryujinx.Core.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
|
||||
|
||||
namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
{
|
||||
class IApplicationFunctions : IIpcService
|
||||
class IApplicationFunctions : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IApplicationFunctions()
|
||||
{
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
using Ryujinx.Core.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
|
||||
|
||||
namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
{
|
||||
class IApplicationProxy : IIpcService
|
||||
class IApplicationProxy : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IApplicationProxy()
|
||||
{
|
||||
|
||||
@@ -3,11 +3,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
{
|
||||
class IAudioController : IIpcService
|
||||
class IAudioController : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IAudioController()
|
||||
{
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
using Ryujinx.Core.OsHle.Handles;
|
||||
using Ryujinx.Core.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using static Ryujinx.Core.OsHle.ErrorCode;
|
||||
|
||||
namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
{
|
||||
class ICommonStateGetter : IIpcService
|
||||
class ICommonStateGetter : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public ICommonStateGetter()
|
||||
{
|
||||
@@ -17,37 +20,31 @@ namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
{ 1, ReceiveMessage },
|
||||
{ 5, GetOperationMode },
|
||||
{ 6, GetPerformanceMode },
|
||||
{ 9, GetCurrentFocusState },
|
||||
{ 9, GetCurrentFocusState }
|
||||
};
|
||||
}
|
||||
|
||||
private enum FocusState
|
||||
{
|
||||
InFocus = 1,
|
||||
OutOfFocus = 2
|
||||
}
|
||||
|
||||
private enum OperationMode
|
||||
{
|
||||
Handheld = 0,
|
||||
Docked = 1
|
||||
}
|
||||
|
||||
public long GetEventHandle(ServiceCtx Context)
|
||||
{
|
||||
Context.ResponseData.Write(0L);
|
||||
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)
|
||||
{
|
||||
//Program expects 0xF at 0x17ae70 on puyo sdk,
|
||||
//otherwise runs on a infinite loop until it reads said value.
|
||||
//What it means is still unknown.
|
||||
Context.ResponseData.Write(0xfL);
|
||||
if (!Context.Process.AppletState.TryDequeueMessage(out MessageInfo Message))
|
||||
{
|
||||
return MakeError(ErrorModule.Am, AmErr.NoMessages);
|
||||
}
|
||||
|
||||
return 0; //0x680;
|
||||
Context.ResponseData.Write((int)Message);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long GetOperationMode(ServiceCtx Context)
|
||||
@@ -66,7 +63,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
|
||||
public long GetCurrentFocusState(ServiceCtx Context)
|
||||
{
|
||||
Context.ResponseData.Write((byte)FocusState.InFocus);
|
||||
Context.ResponseData.Write((byte)Context.Process.AppletState.FocusState);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
{
|
||||
class IDebugFunctions : IIpcService
|
||||
class IDebugFunctions : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IDebugFunctions()
|
||||
{
|
||||
|
||||
@@ -3,11 +3,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
{
|
||||
class IDisplayController : IIpcService
|
||||
class IDisplayController : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IDisplayController()
|
||||
{
|
||||
|
||||
@@ -3,11 +3,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
{
|
||||
class ILibraryAppletCreator : IIpcService
|
||||
class ILibraryAppletCreator : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public ILibraryAppletCreator()
|
||||
{
|
||||
|
||||
@@ -3,11 +3,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
{
|
||||
class ISelfController : IIpcService
|
||||
class ISelfController : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public ISelfController()
|
||||
{
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
using Ryujinx.Core.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using static Ryujinx.Core.OsHle.IpcServices.ObjHelper;
|
||||
|
||||
namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
{
|
||||
class IStorage : IIpcService
|
||||
class IStorage : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public byte[] Data { get; private set; }
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
{
|
||||
class IStorageAccessor : IIpcService
|
||||
class IStorageAccessor : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
private IStorage Storage;
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
{
|
||||
class IWindowController : IIpcService
|
||||
class IWindowController : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public IWindowController()
|
||||
{
|
||||
|
||||
9
Ryujinx.Core/OsHle/Services/Am/MessageInfo.cs
Normal file
9
Ryujinx.Core/OsHle/Services/Am/MessageInfo.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
{
|
||||
enum MessageInfo
|
||||
{
|
||||
FocusStateChanged = 0xf,
|
||||
OperationModeChanged = 0x1e,
|
||||
PerformanceModeChanged = 0x1f
|
||||
}
|
||||
}
|
||||
8
Ryujinx.Core/OsHle/Services/Am/OperationMode.cs
Normal file
8
Ryujinx.Core/OsHle/Services/Am/OperationMode.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Ryujinx.Core.OsHle.IpcServices.Am
|
||||
{
|
||||
enum OperationMode
|
||||
{
|
||||
Handheld = 0,
|
||||
Docked = 1
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,13 @@
|
||||
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
|
||||
class ServiceAppletOE : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
public ServiceAppletOE()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user