Refactoring result codes (#731)

* refactoring result codes

- Add a main enum who can handle some orphalin result codes and the default `ResultCode.Success` one.
- Add sub-enum by services when it's needed.
- Remove some empty line.
- Recast all service calls to ResultCode.
- Remove some unneeded static declaration.
- Delete unused `NvHelper` class.

* NvResult is back

* Fix
This commit is contained in:
Ac_K 2019-07-14 21:04:38 +02:00 committed by gdkchan
parent 4926f6523d
commit 4ad3936afd
147 changed files with 1413 additions and 1477 deletions

View file

@ -5,8 +5,6 @@ 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
@ -15,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm
[Command(4)]
// CreateRequest(u32) -> object<nn::nifm::detail::IRequest>
public long CreateRequest(ServiceCtx context)
public ResultCode CreateRequest(ServiceCtx context)
{
int unknown = context.RequestData.ReadInt32();
@ -23,16 +21,16 @@ namespace Ryujinx.HLE.HOS.Services.Nifm
Logger.PrintStub(LogClass.ServiceNifm);
return 0;
return ResultCode.Success;
}
[Command(12)]
// GetCurrentIpAddress() -> nn::nifm::IpV4Address
public long GetCurrentIpAddress(ServiceCtx context)
public ResultCode GetCurrentIpAddress(ServiceCtx context)
{
if (!NetworkInterface.GetIsNetworkAvailable())
{
return MakeError(ErrorModule.Nifm, NifmErr.NoInternetConnection);
return ResultCode.NoInternetConnection;
}
IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
@ -43,7 +41,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm
Logger.PrintInfo(LogClass.ServiceNifm, $"Console's local IP is \"{address}\".");
return 0;
return ResultCode.Success;
}
}
}

View file

@ -19,27 +19,27 @@ namespace Ryujinx.HLE.HOS.Services.Nifm
[Command(0)]
// GetRequestState() -> u32
public long GetRequestState(ServiceCtx context)
public ResultCode GetRequestState(ServiceCtx context)
{
context.ResponseData.Write(1);
Logger.PrintStub(LogClass.ServiceNifm);
return 0;
return ResultCode.Success;
}
[Command(1)]
// GetResult()
public long GetResult(ServiceCtx context)
public ResultCode GetResult(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceNifm);
return 0;
return ResultCode.Success;
}
[Command(2)]
// GetSystemEventReadableHandles() -> (handle<copy>, handle<copy>)
public long GetSystemEventReadableHandles(ServiceCtx context)
public ResultCode GetSystemEventReadableHandles(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_event0.ReadableEvent, out int handle0) != KernelResult.Success)
{
@ -53,34 +53,34 @@ namespace Ryujinx.HLE.HOS.Services.Nifm
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle0, handle1);
return 0;
return ResultCode.Success;
}
[Command(3)]
// Cancel()
public long Cancel(ServiceCtx context)
public ResultCode Cancel(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceNifm);
return 0;
return ResultCode.Success;
}
[Command(4)]
// Submit()
public long Submit(ServiceCtx context)
public ResultCode Submit(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceNifm);
return 0;
return ResultCode.Success;
}
[Command(11)]
// SetConnectionConfirmationOption(i8)
public long SetConnectionConfirmationOption(ServiceCtx context)
public ResultCode SetConnectionConfirmationOption(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceNifm);
return 0;
return ResultCode.Success;
}
}
}

View file

@ -7,20 +7,20 @@ namespace Ryujinx.HLE.HOS.Services.Nifm
[Command(4)]
// CreateGeneralServiceOld() -> object<nn::nifm::detail::IGeneralService>
public long CreateGeneralServiceOld(ServiceCtx context)
public ResultCode CreateGeneralServiceOld(ServiceCtx context)
{
MakeObject(context, new IGeneralService());
return 0;
return ResultCode.Success;
}
[Command(5)] // 3.0.0+
// CreateGeneralService(u64, pid) -> object<nn::nifm::detail::IGeneralService>
public long CreateGeneralService(ServiceCtx context)
public ResultCode CreateGeneralService(ServiceCtx context)
{
MakeObject(context, new IGeneralService());
return 0;
return ResultCode.Success;
}
}
}

View file

@ -1,7 +0,0 @@
namespace Ryujinx.HLE.HOS.Services.Nifm
{
static class NifmErr
{
public const int NoInternetConnection = 300;
}
}

View file

@ -0,0 +1,12 @@
namespace Ryujinx.HLE.HOS.Services.Nifm
{
enum ResultCode
{
ModuleId = 110,
ErrorCodeShift = 9,
Success = 0,
NoInternetConnection = (300 << ErrorCodeShift) | ModuleId
}
}