aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Nifm
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-08-16 20:47:36 -0300
committerGitHub <noreply@github.com>2018-08-16 20:47:36 -0300
commit521751795a1c97c0d97f6f8904a3be69b13d3a9d (patch)
tree942a05899c40e2de6d92a38b93a494bd96ee64b8 /Ryujinx.HLE/HOS/Services/Nifm
parent182d716867ae477c2b15a5332430dc2641fa1cc3 (diff)
Code style fixes and nits on the HLE project (#355)
* Some style fixes and nits on ITimeZoneService * Remove some unneeded usings * Remove the Ryujinx.HLE.OsHle.Handles namespace * Remove hbmenu automatic load on process exit * Rename Ns to Device, rename Os to System, rename SystemState to State * Move Exceptions and Utilities out of OsHle * Rename OsHle to HOS * Rename OsHle folder to HOS * IManagerDisplayService and ISystemDisplayService style fixes * BsdError shouldn't be public * Add a empty new line before using static * Remove unused file * Some style fixes on NPDM * Exit gracefully when the application is closed * Code style fixes on IGeneralService * Add 0x prefix on values printed as hex * Small improvements on finalization code * Move ProcessId and ThreadId out of AThreadState * Rename VFs to FileSystem * FsAccessHeader shouldn't be public. Also fix file names casing * More case changes on NPDM * Remove unused files * Move using to the correct place on NPDM * Use properties on KernelAccessControlMmio * Address PR feedback
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Nifm')
-rw-r--r--Ryujinx.HLE/HOS/Services/Nifm/IGeneralService.cs58
-rw-r--r--Ryujinx.HLE/HOS/Services/Nifm/IRequest.cs95
-rw-r--r--Ryujinx.HLE/HOS/Services/Nifm/IStaticService.cs35
-rw-r--r--Ryujinx.HLE/HOS/Services/Nifm/NifmErr.cs7
4 files changed, 195 insertions, 0 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Nifm/IGeneralService.cs b/Ryujinx.HLE/HOS/Services/Nifm/IGeneralService.cs
new file mode 100644
index 00000000..ec68247b
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Nifm/IGeneralService.cs
@@ -0,0 +1,58 @@
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.NetworkInformation;
+using System.Net.Sockets;
+
+using static Ryujinx.HLE.HOS.ErrorCode;
+
+namespace Ryujinx.HLE.HOS.Services.Nifm
+{
+ class IGeneralService : IpcService
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ public IGeneralService()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ { 4, CreateRequest },
+ { 12, GetCurrentIpAddress }
+ };
+ }
+
+ public long CreateRequest(ServiceCtx Context)
+ {
+ int Unknown = Context.RequestData.ReadInt32();
+
+ MakeObject(Context, new IRequest());
+
+ Context.Device.Log.PrintStub(LogClass.ServiceNifm, "Stubbed.");
+
+ return 0;
+ }
+
+ public long GetCurrentIpAddress(ServiceCtx Context)
+ {
+ if (!NetworkInterface.GetIsNetworkAvailable())
+ {
+ return MakeError(ErrorModule.Nifm, NifmErr.NoInternetConnection);
+ }
+
+ IPHostEntry Host = Dns.GetHostEntry(Dns.GetHostName());
+
+ IPAddress Address = Host.AddressList.FirstOrDefault(A => A.AddressFamily == AddressFamily.InterNetwork);
+
+ Context.ResponseData.Write(BitConverter.ToUInt32(Address.GetAddressBytes()));
+
+ Context.Device.Log.PrintInfo(LogClass.ServiceNifm, $"Console's local IP is \"{Address}\".");
+
+ return 0;
+ }
+ }
+}
diff --git a/Ryujinx.HLE/HOS/Services/Nifm/IRequest.cs b/Ryujinx.HLE/HOS/Services/Nifm/IRequest.cs
new file mode 100644
index 00000000..7bd30ff9
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Nifm/IRequest.cs
@@ -0,0 +1,95 @@
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.Kernel;
+using Ryujinx.HLE.Logging;
+using System;
+using System.Collections.Generic;
+
+namespace Ryujinx.HLE.HOS.Services.Nifm
+{
+ class IRequest : IpcService, IDisposable
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ private KEvent Event0;
+ private KEvent Event1;
+
+ public IRequest()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ { 0, GetRequestState },
+ { 1, GetResult },
+ { 2, GetSystemEventReadableHandles },
+ { 3, Cancel },
+ { 4, Submit },
+ { 11, SetConnectionConfirmationOption }
+ };
+
+ Event0 = new KEvent();
+ Event1 = new KEvent();
+ }
+
+ public long GetRequestState(ServiceCtx Context)
+ {
+ Context.ResponseData.Write(1);
+
+ Context.Device.Log.PrintStub(LogClass.ServiceNifm, "Stubbed.");
+
+ return 0;
+ }
+
+ public long GetResult(ServiceCtx Context)
+ {
+ Context.Device.Log.PrintStub(LogClass.ServiceNifm, "Stubbed.");
+
+ return 0;
+ }
+
+ public long GetSystemEventReadableHandles(ServiceCtx Context)
+ {
+ int Handle0 = Context.Process.HandleTable.OpenHandle(Event0);
+ int Handle1 = Context.Process.HandleTable.OpenHandle(Event1);
+
+ Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle0, Handle1);
+
+ return 0;
+ }
+
+ public long Cancel(ServiceCtx Context)
+ {
+ Context.Device.Log.PrintStub(LogClass.ServiceNifm, "Stubbed.");
+
+ return 0;
+ }
+
+ public long Submit(ServiceCtx Context)
+ {
+ Context.Device.Log.PrintStub(LogClass.ServiceNifm, "Stubbed.");
+
+ return 0;
+ }
+
+ public long SetConnectionConfirmationOption(ServiceCtx Context)
+ {
+ Context.Device.Log.PrintStub(LogClass.ServiceNifm, "Stubbed.");
+
+ return 0;
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ }
+
+ protected virtual void Dispose(bool Disposing)
+ {
+ if (Disposing)
+ {
+ Event0.Dispose();
+ Event1.Dispose();
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Nifm/IStaticService.cs b/Ryujinx.HLE/HOS/Services/Nifm/IStaticService.cs
new file mode 100644
index 00000000..19e7d247
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Nifm/IStaticService.cs
@@ -0,0 +1,35 @@
+using Ryujinx.HLE.HOS.Ipc;
+using System.Collections.Generic;
+
+namespace Ryujinx.HLE.HOS.Services.Nifm
+{
+ class IStaticService : IpcService
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ public IStaticService()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ { 4, CreateGeneralServiceOld },
+ { 5, CreateGeneralService }
+ };
+ }
+
+ public long CreateGeneralServiceOld(ServiceCtx Context)
+ {
+ MakeObject(Context, new IGeneralService());
+
+ return 0;
+ }
+
+ public long CreateGeneralService(ServiceCtx Context)
+ {
+ MakeObject(Context, new IGeneralService());
+
+ return 0;
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Nifm/NifmErr.cs b/Ryujinx.HLE/HOS/Services/Nifm/NifmErr.cs
new file mode 100644
index 00000000..3abeb838
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Nifm/NifmErr.cs
@@ -0,0 +1,7 @@
+namespace Ryujinx.HLE.HOS.Services.Nifm
+{
+ static class NifmErr
+ {
+ public const int NoInternetConnection = 300;
+ }
+} \ No newline at end of file