aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Core/OsHle/Objects/Am
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Core/OsHle/Objects/Am')
-rw-r--r--Ryujinx.Core/OsHle/Objects/Am/IApplicationFunctions.cs80
-rw-r--r--Ryujinx.Core/OsHle/Objects/Am/IApplicationProxy.cs85
-rw-r--r--Ryujinx.Core/OsHle/Objects/Am/IAudioController.cs20
-rw-r--r--Ryujinx.Core/OsHle/Objects/Am/ICommonStateGetter.cs74
-rw-r--r--Ryujinx.Core/OsHle/Objects/Am/IDebugFunctions.cs20
-rw-r--r--Ryujinx.Core/OsHle/Objects/Am/IDisplayController.cs20
-rw-r--r--Ryujinx.Core/OsHle/Objects/Am/ILibraryAppletCreator.cs20
-rw-r--r--Ryujinx.Core/OsHle/Objects/Am/IParentalControlService.cs20
-rw-r--r--Ryujinx.Core/OsHle/Objects/Am/ISelfController.cs53
-rw-r--r--Ryujinx.Core/OsHle/Objects/Am/IStorage.cs33
-rw-r--r--Ryujinx.Core/OsHle/Objects/Am/IStorageAccessor.cs62
-rw-r--r--Ryujinx.Core/OsHle/Objects/Am/IWindowController.cs33
12 files changed, 520 insertions, 0 deletions
diff --git a/Ryujinx.Core/OsHle/Objects/Am/IApplicationFunctions.cs b/Ryujinx.Core/OsHle/Objects/Am/IApplicationFunctions.cs
new file mode 100644
index 00000000..939ad248
--- /dev/null
+++ b/Ryujinx.Core/OsHle/Objects/Am/IApplicationFunctions.cs
@@ -0,0 +1,80 @@
+using Ryujinx.Core.OsHle.Ipc;
+using System.Collections.Generic;
+using System.IO;
+
+using static Ryujinx.Core.OsHle.Objects.ObjHelper;
+
+namespace Ryujinx.Core.OsHle.Objects.Am
+{
+ class IApplicationFunctions : IIpcInterface
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ public IApplicationFunctions()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ { 1, PopLaunchParameter },
+ { 20, EnsureSaveData },
+ { 21, GetDesiredLanguage },
+ { 40, NotifyRunning }
+ };
+ }
+
+ 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()));
+
+ return 0;
+ }
+
+ public long EnsureSaveData(ServiceCtx Context)
+ {
+ long UIdLow = Context.RequestData.ReadInt64();
+ long UIdHigh = Context.RequestData.ReadInt64();
+
+ Context.ResponseData.Write(0L);
+
+ return 0;
+ }
+
+ public long GetDesiredLanguage(ServiceCtx Context)
+ {
+ //This is an enumerator where each number is a differnet language.
+ //0 is Japanese and 1 is English, need to figure out the other codes.
+ Context.ResponseData.Write(1L);
+
+ return 0;
+ }
+
+ public long NotifyRunning(ServiceCtx Context)
+ {
+ Context.ResponseData.Write(1);
+
+ return 0;
+ }
+
+ private 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();
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Core/OsHle/Objects/Am/IApplicationProxy.cs b/Ryujinx.Core/OsHle/Objects/Am/IApplicationProxy.cs
new file mode 100644
index 00000000..4a164daf
--- /dev/null
+++ b/Ryujinx.Core/OsHle/Objects/Am/IApplicationProxy.cs
@@ -0,0 +1,85 @@
+using Ryujinx.Core.OsHle.Ipc;
+using System.Collections.Generic;
+
+using static Ryujinx.Core.OsHle.Objects.ObjHelper;
+
+namespace Ryujinx.Core.OsHle.Objects.Am
+{
+ class IApplicationProxy : IIpcInterface
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public 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;
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Core/OsHle/Objects/Am/IAudioController.cs b/Ryujinx.Core/OsHle/Objects/Am/IAudioController.cs
new file mode 100644
index 00000000..c37042fd
--- /dev/null
+++ b/Ryujinx.Core/OsHle/Objects/Am/IAudioController.cs
@@ -0,0 +1,20 @@
+using Ryujinx.Core.OsHle.Ipc;
+using System.Collections.Generic;
+
+namespace Ryujinx.Core.OsHle.Objects.Am
+{
+ class IAudioController : IIpcInterface
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ public IAudioController()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ //...
+ };
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Core/OsHle/Objects/Am/ICommonStateGetter.cs b/Ryujinx.Core/OsHle/Objects/Am/ICommonStateGetter.cs
new file mode 100644
index 00000000..83d61fa6
--- /dev/null
+++ b/Ryujinx.Core/OsHle/Objects/Am/ICommonStateGetter.cs
@@ -0,0 +1,74 @@
+using Ryujinx.Core.OsHle.Ipc;
+using System.Collections.Generic;
+
+namespace Ryujinx.Core.OsHle.Objects.Am
+{
+ class ICommonStateGetter : IIpcInterface
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ public ICommonStateGetter()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ { 0, GetEventHandle },
+ { 1, ReceiveMessage },
+ { 5, GetOperationMode },
+ { 6, GetPerformanceMode },
+ { 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);
+
+ 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);
+
+ return 0; //0x680;
+ }
+
+ public long GetOperationMode(ServiceCtx Context)
+ {
+ Context.ResponseData.Write((byte)OperationMode.Handheld);
+
+ return 0;
+ }
+
+ public long GetPerformanceMode(ServiceCtx Context)
+ {
+ Context.ResponseData.Write((byte)0);
+
+ return 0;
+ }
+
+ public long GetCurrentFocusState(ServiceCtx Context)
+ {
+ Context.ResponseData.Write((byte)FocusState.InFocus);
+
+ return 0;
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Core/OsHle/Objects/Am/IDebugFunctions.cs b/Ryujinx.Core/OsHle/Objects/Am/IDebugFunctions.cs
new file mode 100644
index 00000000..d04d8363
--- /dev/null
+++ b/Ryujinx.Core/OsHle/Objects/Am/IDebugFunctions.cs
@@ -0,0 +1,20 @@
+using Ryujinx.Core.OsHle.Ipc;
+using System.Collections.Generic;
+
+namespace Ryujinx.Core.OsHle.Objects.Am
+{
+ class IDebugFunctions : IIpcInterface
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ public IDebugFunctions()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ //...
+ };
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Core/OsHle/Objects/Am/IDisplayController.cs b/Ryujinx.Core/OsHle/Objects/Am/IDisplayController.cs
new file mode 100644
index 00000000..9eafa70d
--- /dev/null
+++ b/Ryujinx.Core/OsHle/Objects/Am/IDisplayController.cs
@@ -0,0 +1,20 @@
+using Ryujinx.Core.OsHle.Ipc;
+using System.Collections.Generic;
+
+namespace Ryujinx.Core.OsHle.Objects.Am
+{
+ class IDisplayController : IIpcInterface
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ public IDisplayController()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ //...
+ };
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Core/OsHle/Objects/Am/ILibraryAppletCreator.cs b/Ryujinx.Core/OsHle/Objects/Am/ILibraryAppletCreator.cs
new file mode 100644
index 00000000..10e0f4f4
--- /dev/null
+++ b/Ryujinx.Core/OsHle/Objects/Am/ILibraryAppletCreator.cs
@@ -0,0 +1,20 @@
+using Ryujinx.Core.OsHle.Ipc;
+using System.Collections.Generic;
+
+namespace Ryujinx.Core.OsHle.Objects.Am
+{
+ class ILibraryAppletCreator : IIpcInterface
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ public ILibraryAppletCreator()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ //...
+ };
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Core/OsHle/Objects/Am/IParentalControlService.cs b/Ryujinx.Core/OsHle/Objects/Am/IParentalControlService.cs
new file mode 100644
index 00000000..1feacfa6
--- /dev/null
+++ b/Ryujinx.Core/OsHle/Objects/Am/IParentalControlService.cs
@@ -0,0 +1,20 @@
+using Ryujinx.Core.OsHle.Ipc;
+using System.Collections.Generic;
+
+namespace Ryujinx.Core.OsHle.Objects.Am
+{
+ class IParentalControlService : IIpcInterface
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ public IParentalControlService()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ //...
+ };
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Core/OsHle/Objects/Am/ISelfController.cs b/Ryujinx.Core/OsHle/Objects/Am/ISelfController.cs
new file mode 100644
index 00000000..691bb202
--- /dev/null
+++ b/Ryujinx.Core/OsHle/Objects/Am/ISelfController.cs
@@ -0,0 +1,53 @@
+using Ryujinx.Core.OsHle.Ipc;
+using System.Collections.Generic;
+
+namespace Ryujinx.Core.OsHle.Objects.Am
+{
+ class ISelfController : IIpcInterface
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ public ISelfController()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ { 11, SetOperationModeChangedNotification },
+ { 12, SetPerformanceModeChangedNotification },
+ { 13, SetFocusHandlingMode },
+ { 16, SetOutOfFocusSuspendingEnabled }
+ };
+ }
+
+ public long SetOperationModeChangedNotification(ServiceCtx Context)
+ {
+ bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
+
+ return 0;
+ }
+
+ public long SetPerformanceModeChangedNotification(ServiceCtx Context)
+ {
+ bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
+
+ 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;
+
+ return 0;
+ }
+
+ public long SetOutOfFocusSuspendingEnabled(ServiceCtx Context)
+ {
+ bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
+
+ return 0;
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Core/OsHle/Objects/Am/IStorage.cs b/Ryujinx.Core/OsHle/Objects/Am/IStorage.cs
new file mode 100644
index 00000000..b30059ba
--- /dev/null
+++ b/Ryujinx.Core/OsHle/Objects/Am/IStorage.cs
@@ -0,0 +1,33 @@
+using Ryujinx.Core.OsHle.Ipc;
+using System.Collections.Generic;
+
+using static Ryujinx.Core.OsHle.Objects.ObjHelper;
+
+namespace Ryujinx.Core.OsHle.Objects.Am
+{
+ class IStorage : IIpcInterface
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public 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;
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Core/OsHle/Objects/Am/IStorageAccessor.cs b/Ryujinx.Core/OsHle/Objects/Am/IStorageAccessor.cs
new file mode 100644
index 00000000..df260cc3
--- /dev/null
+++ b/Ryujinx.Core/OsHle/Objects/Am/IStorageAccessor.cs
@@ -0,0 +1,62 @@
+using ChocolArm64.Memory;
+using Ryujinx.Core.OsHle.Ipc;
+using System;
+using System.Collections.Generic;
+
+namespace Ryujinx.Core.OsHle.Objects.Am
+{
+ class IStorageAccessor : IIpcInterface
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ private IStorage Storage;
+
+ public IStorageAccessor(IStorage Storage)
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ { 0, GetSize },
+ { 11, Read }
+ };
+
+ this.Storage = Storage;
+ }
+
+ public long GetSize(ServiceCtx Context)
+ {
+ Context.ResponseData.Write((long)Storage.Data.Length);
+
+ return 0;
+ }
+
+ public long Read(ServiceCtx Context)
+ {
+ long ReadPosition = Context.RequestData.ReadInt64();
+
+ if (Context.Request.RecvListBuff.Count > 0)
+ {
+ long Position = Context.Request.RecvListBuff[0].Position;
+ short Size = Context.Request.RecvListBuff[0].Size;
+
+ byte[] Data;
+
+ if (Storage.Data.Length > Size)
+ {
+ Data = new byte[Size];
+
+ Buffer.BlockCopy(Storage.Data, 0, Data, 0, Size);
+ }
+ else
+ {
+ Data = Storage.Data;
+ }
+
+ AMemoryHelper.WriteBytes(Context.Memory, Position, Data);
+ }
+
+ return 0;
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Core/OsHle/Objects/Am/IWindowController.cs b/Ryujinx.Core/OsHle/Objects/Am/IWindowController.cs
new file mode 100644
index 00000000..aa6e961e
--- /dev/null
+++ b/Ryujinx.Core/OsHle/Objects/Am/IWindowController.cs
@@ -0,0 +1,33 @@
+using Ryujinx.Core.OsHle.Ipc;
+using System.Collections.Generic;
+
+namespace Ryujinx.Core.OsHle.Objects.Am
+{
+ class IWindowController : IIpcInterface
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ public IWindowController()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ { 1, GetAppletResourceUserId },
+ { 10, AcquireForegroundRights }
+ };
+ }
+
+ public long GetAppletResourceUserId(ServiceCtx Context)
+ {
+ Context.ResponseData.Write(0L);
+
+ return 0;
+ }
+
+ public long AcquireForegroundRights(ServiceCtx Context)
+ {
+ return 0;
+ }
+ }
+} \ No newline at end of file