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

@ -1,10 +0,0 @@
namespace Ryujinx.HLE.HOS
{
static class ErrorCode
{
public static uint MakeError(ErrorModule module, int code)
{
return (uint)module | ((uint)code << 9);
}
}
}

View File

@ -1,101 +0,0 @@
namespace Ryujinx.HLE.HOS
{
enum ErrorModule
{
Kernel = 1,
Fs = 2,
Os = 3, // (Memory, Thread, Mutex, NVIDIA)
Htcs = 4,
Ncm = 5,
Dd = 6,
DebugMonitor = 7,
Lr = 8,
Loader = 9,
IpcCommandInterface = 10,
Ipc = 11,
Pm = 15,
Ns = 16,
Socket = 17,
Htc = 18,
NcmContent = 20,
Sm = 21,
RoUserland = 22,
SdMmc = 24,
Ovln = 25,
Spl = 26,
Ethc = 100,
I2C = 101,
Gpio = 102,
Uart = 103,
Settings = 105,
Wlan = 107,
Xcd = 108,
Nifm = 110,
Hwopus = 111,
Bluetooth = 113,
Vi = 114,
Nfp = 115,
Time = 116,
Fgm = 117,
Oe = 118,
Pcie = 120,
Friends = 121,
Bcat = 122,
Ssl = 123,
Account = 124,
News = 125,
Mii = 126,
Nfc = 127,
Am = 128,
PlayReport = 129,
Ahid = 130,
Qlaunch = 132,
Pcv = 133,
Omm = 134,
Bpc = 135,
Psm = 136,
Nim = 137,
Psc = 138,
Tc = 139,
Usb = 140,
Nsd = 141,
Pctl = 142,
Btm = 143,
Ec = 144,
ETicket = 145,
Ngc = 146,
ErrorReport = 147,
Apm = 148,
Profiler = 150,
ErrorUpload = 151,
Audio = 153,
Npns = 154,
NpnsHttpStream = 155,
Arp = 157,
Swkbd = 158,
Boot = 159,
NfcMifare = 161,
UserlandAssert = 162,
Fatal = 163,
NimShop = 164,
Spsm = 165,
Bgtc = 167,
UserlandCrash = 168,
SRepo = 180,
Dauth = 181,
Hid = 202,
Ldn = 203,
Irsensor = 205,
Capture = 206,
Manu = 208,
Atk = 209,
Web = 210,
Grc = 212,
Migration = 216,
MigrationLdcServer = 217,
GeneralWebApplet = 800,
WifiWebAuthApplet = 809,
WhitelistedApplet = 810,
ShopN = 811
}
}

View File

@ -0,0 +1,12 @@
namespace Ryujinx.HLE.HOS
{
public enum ResultCode
{
OsModuleId = 3,
ErrorCodeShift = 9,
Success = 0,
NotAllocated = (1023 << ErrorCodeShift) | OsModuleId
}
}

View File

@ -1,15 +0,0 @@
namespace Ryujinx.HLE.HOS.Services.Acc
{
static class AccErr
{
public const int NullArgument = 20;
public const int InvalidArgument = 22;
public const int NullInputBuffer = 30;
public const int InvalidInputBufferSize = 31;
public const int InvalidInputBuffer = 32;
public const int ApplicationLaunchPropertyAlreadyInit = 41;
public const int UserNotFound = 100;
public const int NullObject = 302;
public const int UnknownError1 = 341;
}
}

View File

@ -5,4 +5,4 @@ namespace Ryujinx.HLE.HOS.SystemState
Closed,
Open
}
}
}

View File

@ -34,4 +34,4 @@ namespace Ryujinx.HLE.HOS.SystemState
LastModifiedTimestamp = (long)(DateTime.Now - Epoch).TotalSeconds;
}
}
}
}

View File

@ -6,8 +6,6 @@ using Ryujinx.HLE.Utilities;
using System;
using System.Collections.Generic;
using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.HOS.Services.Acc
{
[Service("acc:u0")]
@ -22,48 +20,48 @@ namespace Ryujinx.HLE.HOS.Services.Acc
[Command(0)]
// GetUserCount() -> i32
public long GetUserCount(ServiceCtx context)
public ResultCode GetUserCount(ServiceCtx context)
{
context.ResponseData.Write(context.Device.System.State.Account.GetUserCount());
return 0;
return ResultCode.Success;
}
[Command(1)]
// GetUserExistence(nn::account::Uid) -> bool
public long GetUserExistence(ServiceCtx context)
public ResultCode GetUserExistence(ServiceCtx context)
{
UInt128 userId = new UInt128(context.RequestData.ReadBytes(0x10));
if (userId.IsNull)
{
return MakeError(ErrorModule.Account, AccErr.NullArgument);
return ResultCode.NullArgument;
}
context.ResponseData.Write(context.Device.System.State.Account.TryGetUser(userId, out _));
return 0;
return ResultCode.Success;
}
[Command(2)]
// ListAllUsers() -> array<nn::account::Uid, 0xa>
public long ListAllUsers(ServiceCtx context)
public ResultCode ListAllUsers(ServiceCtx context)
{
return WriteUserList(context, context.Device.System.State.Account.GetAllUsers());
}
[Command(3)]
// ListOpenUsers() -> array<nn::account::Uid, 0xa>
public long ListOpenUsers(ServiceCtx context)
public ResultCode ListOpenUsers(ServiceCtx context)
{
return WriteUserList(context, context.Device.System.State.Account.GetOpenedUsers());
}
private long WriteUserList(ServiceCtx context, IEnumerable<UserProfile> profiles)
private ResultCode WriteUserList(ServiceCtx context, IEnumerable<UserProfile> profiles)
{
if (context.Request.RecvListBuff.Count == 0)
{
return MakeError(ErrorModule.Account, AccErr.InvalidInputBuffer);
return ResultCode.InvalidInputBuffer;
}
long outputPosition = context.Request.RecvListBuff[0].Position;
@ -84,21 +82,21 @@ namespace Ryujinx.HLE.HOS.Services.Acc
offset += 0x10;
}
return 0;
return ResultCode.Success;
}
[Command(4)]
// GetLastOpenedUser() -> nn::account::Uid
public long GetLastOpenedUser(ServiceCtx context)
public ResultCode GetLastOpenedUser(ServiceCtx context)
{
context.Device.System.State.Account.LastOpenedUser.UserId.Write(context.ResponseData);
return 0;
return ResultCode.Success;
}
[Command(5)]
// GetProfile(nn::account::Uid) -> object<nn::account::profile::IProfile>
public long GetProfile(ServiceCtx context)
public ResultCode GetProfile(ServiceCtx context)
{
UInt128 userId = new UInt128(context.RequestData.ReadBytes(0x10));
@ -106,7 +104,7 @@ namespace Ryujinx.HLE.HOS.Services.Acc
{
Logger.PrintWarning(LogClass.ServiceAcc, $"User 0x{userId} not found!");
return MakeError(ErrorModule.Account, AccErr.UserNotFound);
return ResultCode.UserNotFound;
}
MakeObject(context, new IProfile(userProfile));
@ -114,22 +112,22 @@ namespace Ryujinx.HLE.HOS.Services.Acc
// Doesn't occur in our case.
// return MakeError(ErrorModule.Account, AccErr.NullObject);
return 0;
return ResultCode.Success;
}
[Command(50)]
// IsUserRegistrationRequestPermitted(u64, pid) -> bool
public long IsUserRegistrationRequestPermitted(ServiceCtx context)
public ResultCode IsUserRegistrationRequestPermitted(ServiceCtx context)
{
// The u64 argument seems to be unused by account.
context.ResponseData.Write(_userRegistrationRequestPermitted);
return 0;
return ResultCode.Success;
}
[Command(51)]
// TrySelectUserWithoutInteraction(bool) -> nn::account::Uid
public long TrySelectUserWithoutInteraction(ServiceCtx context)
public ResultCode TrySelectUserWithoutInteraction(ServiceCtx context)
{
if (context.Device.System.State.Account.GetUserCount() != 1)
{
@ -152,18 +150,18 @@ namespace Ryujinx.HLE.HOS.Services.Acc
// As we returned an invalid UserId if there is more than one user earlier, now we can return only the first one.
context.Device.System.State.Account.GetFirst().UserId.Write(context.ResponseData);
return 0;
return ResultCode.Success;
}
[Command(100)]
[Command(140)] // 6.0.0+
// InitializeApplicationInfo(u64, pid)
// Both calls (100, 140) use the same submethod, maybe there's something different further along when arp:r is called?
public long InitializeApplicationInfo(ServiceCtx context)
public ResultCode InitializeApplicationInfo(ServiceCtx context)
{
if (_applicationLaunchProperty != null)
{
return MakeError(ErrorModule.Account, AccErr.ApplicationLaunchPropertyAlreadyInit);
return ResultCode.ApplicationLaunchPropertyAlreadyInit;
}
// The u64 argument seems to be unused by account.
@ -183,7 +181,7 @@ namespace Ryujinx.HLE.HOS.Services.Acc
UpdateGameStorageId = 0x00;
}
return MakeError(ErrorModule.Account, AccErr.InvalidArgument);
return ResultCode.InvalidArgument;
}
else
*/
@ -199,52 +197,52 @@ namespace Ryujinx.HLE.HOS.Services.Acc
Logger.PrintStub(LogClass.ServiceAcc, new { unknown });
return 0;
return ResultCode.Success;
}
[Command(101)]
// GetBaasAccountManagerForApplication(nn::account::Uid) -> object<nn::account::baas::IManagerForApplication>
public long GetBaasAccountManagerForApplication(ServiceCtx context)
public ResultCode GetBaasAccountManagerForApplication(ServiceCtx context)
{
UInt128 userId = new UInt128(context.RequestData.ReadBytes(0x10));
if (userId.IsNull)
{
return MakeError(ErrorModule.Account, AccErr.NullArgument);
return ResultCode.NullArgument;
}
if (_applicationLaunchProperty == null)
{
return MakeError(ErrorModule.Account, AccErr.InvalidArgument);
return ResultCode.InvalidArgument;
}
MakeObject(context, new IManagerForApplication(userId, _applicationLaunchProperty));
// Doesn't occur in our case.
// return MakeError(ErrorModule.Account, AccErr.NullObject);
// return ResultCode.NullObject;
return 0;
return ResultCode.Success;
}
[Command(110)]
// StoreSaveDataThumbnail(nn::account::Uid, buffer<bytes, 5>)
public long StoreSaveDataThumbnail(ServiceCtx context)
public ResultCode StoreSaveDataThumbnail(ServiceCtx context)
{
if (_applicationLaunchProperty == null)
{
return MakeError(ErrorModule.Account, AccErr.InvalidArgument);
return ResultCode.InvalidArgument;
}
UInt128 userId = new UInt128(context.RequestData.ReadBytes(0x10));
if (userId.IsNull)
{
return MakeError(ErrorModule.Account, AccErr.NullArgument);
return ResultCode.NullArgument;
}
if (context.Request.SendBuff.Count == 0)
{
return MakeError(ErrorModule.Account, AccErr.InvalidInputBuffer);
return ResultCode.InvalidInputBuffer;
}
long inputPosition = context.Request.SendBuff[0].Position;
@ -252,7 +250,7 @@ namespace Ryujinx.HLE.HOS.Services.Acc
if (inputSize != 0x24000)
{
return MakeError(ErrorModule.Account, AccErr.InvalidInputBufferSize);
return ResultCode.InvalidInputBufferSize;
}
byte[] thumbnailBuffer = context.Memory.ReadBytes(inputPosition, inputSize);
@ -261,41 +259,41 @@ namespace Ryujinx.HLE.HOS.Services.Acc
Logger.PrintStub(LogClass.ServiceAcc);
return 0;
return ResultCode.Success;
}
[Command(111)]
// ClearSaveDataThumbnail(nn::account::Uid)
public long ClearSaveDataThumbnail(ServiceCtx context)
public ResultCode ClearSaveDataThumbnail(ServiceCtx context)
{
if (_applicationLaunchProperty == null)
{
return MakeError(ErrorModule.Account, AccErr.InvalidArgument);
return ResultCode.InvalidArgument;
}
UInt128 userId = new UInt128(context.RequestData.ReadBytes(0x10));
if (userId.IsNull)
{
return MakeError(ErrorModule.Account, AccErr.NullArgument);
return ResultCode.NullArgument;
}
// TODO: Clear the Thumbnail somewhere, in save data 0x8000000000000010 ?
Logger.PrintStub(LogClass.ServiceAcc);
return 0;
return ResultCode.Success;
}
[Command(150)] // 6.0.0+
// IsUserAccountSwitchLocked() -> bool
public long IsUserAccountSwitchLocked(ServiceCtx context)
public ResultCode IsUserAccountSwitchLocked(ServiceCtx context)
{
// TODO : Validate the following check.
/*
if (_applicationLaunchProperty != null)
{
return MakeError(ErrorModule.Account, AccErr.ApplicationLaunchPropertyAlreadyInit);
return ResultCode.ApplicationLaunchPropertyAlreadyInit;
}
*/
@ -306,7 +304,7 @@ namespace Ryujinx.HLE.HOS.Services.Acc
Logger.PrintStub(LogClass.ServiceAcc);
return 0;
return ResultCode.Success;
}
}
}

View File

@ -17,16 +17,16 @@ namespace Ryujinx.HLE.HOS.Services.Acc
[Command(0)]
// CheckAvailability()
public long CheckAvailability(ServiceCtx context)
public ResultCode CheckAvailability(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAcc);
return 0;
return ResultCode.Success;
}
[Command(1)]
// GetAccountId() -> nn::account::NetworkServiceAccountId
public long GetAccountId(ServiceCtx context)
public ResultCode GetAccountId(ServiceCtx context)
{
long networkServiceAccountId = 0xcafe;
@ -34,7 +34,7 @@ namespace Ryujinx.HLE.HOS.Services.Acc
context.ResponseData.Write(networkServiceAccountId);
return 0;
return ResultCode.Success;
}
}
}

View File

@ -21,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Acc
[Command(0)]
// Get() -> (nn::account::profile::ProfileBase, buffer<nn::account::profile::UserData, 0x1a>)
public long Get(ServiceCtx context)
public ResultCode Get(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAcc);
@ -38,7 +38,7 @@ namespace Ryujinx.HLE.HOS.Services.Acc
[Command(1)]
// GetBase() -> nn::account::profile::ProfileBase
public long GetBase(ServiceCtx context)
public ResultCode GetBase(ServiceCtx context)
{
_profile.UserId.Write(context.ResponseData);
@ -48,21 +48,21 @@ namespace Ryujinx.HLE.HOS.Services.Acc
context.ResponseData.Write(username);
return 0;
return ResultCode.Success;
}
[Command(10)]
// GetImageSize() -> u32
private long GetImageSize(ServiceCtx context)
private ResultCode GetImageSize(ServiceCtx context)
{
context.ResponseData.Write(_profilePictureStream.Length);
return 0;
return ResultCode.Success;
}
[Command(11)]
// LoadImage() -> (u32, buffer<bytes, 6>)
private long LoadImage(ServiceCtx context)
private ResultCode LoadImage(ServiceCtx context)
{
long bufferPosition = context.Request.ReceiveBuff[0].Position;
long bufferLen = context.Request.ReceiveBuff[0].Size;
@ -75,7 +75,7 @@ namespace Ryujinx.HLE.HOS.Services.Acc
context.ResponseData.Write(_profilePictureStream.Length);
return 0;
return ResultCode.Success;
}
}
}

View File

@ -0,0 +1,20 @@
namespace Ryujinx.HLE.HOS.Services.Acc
{
enum ResultCode
{
ModuleId = 124,
ErrorCodeShift = 9,
Success = 0,
NullArgument = (20 << ErrorCodeShift) | ModuleId,
InvalidArgument = (22 << ErrorCodeShift) | ModuleId,
NullInputBuffer = (30 << ErrorCodeShift) | ModuleId,
InvalidInputBufferSize = (31 << ErrorCodeShift) | ModuleId,
InvalidInputBuffer = (32 << ErrorCodeShift) | ModuleId,
ApplicationLaunchPropertyAlreadyInit = (41 << ErrorCodeShift) | ModuleId,
UserNotFound = (100 << ErrorCodeShift) | ModuleId,
NullObject = (302 << ErrorCodeShift) | ModuleId,
UnknownError1 = (341 << ErrorCodeShift) | ModuleId
}
}

View File

@ -1,7 +0,0 @@
namespace Ryujinx.HLE.HOS.Services.Am
{
static class AmErr
{
public const int NoMessages = 3;
}
}

View File

@ -7,11 +7,11 @@ namespace Ryujinx.HLE.HOS.Services.Am
[Command(100)]
// OpenSystemAppletProxy(u64, pid, handle<copy>) -> object<nn::am::service::ISystemAppletProxy>
public long OpenSystemAppletProxy(ServiceCtx context)
public ResultCode OpenSystemAppletProxy(ServiceCtx context)
{
MakeObject(context, new ISystemAppletProxy());
return 0;
return ResultCode.Success;
}
}
}

View File

@ -8,17 +8,17 @@ namespace Ryujinx.HLE.HOS.Services.Am
[Command(1)]
// PopLaunchParameter(u32) -> object<nn::am::service::IStorage>
public long PopLaunchParameter(ServiceCtx context)
public ResultCode PopLaunchParameter(ServiceCtx context)
{
// Only the first 0x18 bytes of the Data seems to be actually used.
MakeObject(context, new IStorage(StorageHelper.MakeLaunchParams()));
return 0;
return ResultCode.Success;
}
[Command(20)]
// EnsureSaveData(nn::account::Uid) -> u64
public long EnsureSaveData(ServiceCtx context)
public ResultCode EnsureSaveData(ServiceCtx context)
{
long uIdLow = context.RequestData.ReadInt64();
long uIdHigh = context.RequestData.ReadInt64();
@ -27,21 +27,21 @@ namespace Ryujinx.HLE.HOS.Services.Am
context.ResponseData.Write(0L);
return 0;
return ResultCode.Success;
}
[Command(21)]
// GetDesiredLanguage() -> nn::settings::LanguageCode
public long GetDesiredLanguage(ServiceCtx context)
public ResultCode GetDesiredLanguage(ServiceCtx context)
{
context.ResponseData.Write(context.Device.System.State.DesiredLanguageCode);
return 0;
return ResultCode.Success;
}
[Command(22)]
// SetTerminateResult(u32)
public long SetTerminateResult(ServiceCtx context)
public ResultCode SetTerminateResult(ServiceCtx context)
{
int errorCode = context.RequestData.ReadInt32();
@ -49,7 +49,7 @@ namespace Ryujinx.HLE.HOS.Services.Am
Logger.PrintInfo(LogClass.ServiceAm, $"Result = 0x{errorCode:x8} ({result}).");
return 0;
return ResultCode.Success;
}
private string GetFormattedErrorCode(int errorCode)
@ -62,54 +62,54 @@ namespace Ryujinx.HLE.HOS.Services.Am
[Command(23)]
// GetDisplayVersion() -> nn::oe::DisplayVersion
public long GetDisplayVersion(ServiceCtx context)
public ResultCode GetDisplayVersion(ServiceCtx context)
{
// FIXME: Need to check correct version on a switch.
context.ResponseData.Write(1L);
context.ResponseData.Write(0L);
return 0;
return ResultCode.Success;
}
[Command(40)]
// NotifyRunning() -> b8
public long NotifyRunning(ServiceCtx context)
public ResultCode NotifyRunning(ServiceCtx context)
{
context.ResponseData.Write(1);
return 0;
return ResultCode.Success;
}
[Command(50)] // 2.0.0+
// GetPseudoDeviceId() -> nn::util::Uuid
public long GetPseudoDeviceId(ServiceCtx context)
public ResultCode GetPseudoDeviceId(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
context.ResponseData.Write(0L);
context.ResponseData.Write(0L);
return 0;
return ResultCode.Success;
}
[Command(66)] // 3.0.0+
// InitializeGamePlayRecording(u64, handle<copy>)
public long InitializeGamePlayRecording(ServiceCtx context)
public ResultCode InitializeGamePlayRecording(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(67)] // 3.0.0+
// SetGamePlayRecordingState(u32)
public long SetGamePlayRecordingState(ServiceCtx context)
public ResultCode SetGamePlayRecordingState(ServiceCtx context)
{
int state = context.RequestData.ReadInt32();
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
}
}

View File

@ -6,74 +6,74 @@ namespace Ryujinx.HLE.HOS.Services.Am
[Command(0)]
// GetCommonStateGetter() -> object<nn::am::service::ICommonStateGetter>
public long GetCommonStateGetter(ServiceCtx context)
public ResultCode GetCommonStateGetter(ServiceCtx context)
{
MakeObject(context, new ICommonStateGetter(context.Device.System));
return 0;
return ResultCode.Success;
}
[Command(1)]
// GetSelfController() -> object<nn::am::service::ISelfController>
public long GetSelfController(ServiceCtx context)
public ResultCode GetSelfController(ServiceCtx context)
{
MakeObject(context, new ISelfController(context.Device.System));
return 0;
return ResultCode.Success;
}
[Command(2)]
// GetWindowController() -> object<nn::am::service::IWindowController>
public long GetWindowController(ServiceCtx context)
public ResultCode GetWindowController(ServiceCtx context)
{
MakeObject(context, new IWindowController());
return 0;
return ResultCode.Success;
}
[Command(3)]
// GetAudioController() -> object<nn::am::service::IAudioController>
public long GetAudioController(ServiceCtx context)
public ResultCode GetAudioController(ServiceCtx context)
{
MakeObject(context, new IAudioController());
return 0;
return ResultCode.Success;
}
[Command(4)]
// GetDisplayController() -> object<nn::am::service::IDisplayController>
public long GetDisplayController(ServiceCtx context)
public ResultCode GetDisplayController(ServiceCtx context)
{
MakeObject(context, new IDisplayController());
return 0;
return ResultCode.Success;
}
[Command(11)]
// GetLibraryAppletCreator() -> object<nn::am::service::ILibraryAppletCreator>
public long GetLibraryAppletCreator(ServiceCtx context)
public ResultCode GetLibraryAppletCreator(ServiceCtx context)
{
MakeObject(context, new ILibraryAppletCreator());
return 0;
return ResultCode.Success;
}
[Command(20)]
// GetApplicationFunctions() -> object<nn::am::service::IApplicationFunctions>
public long GetApplicationFunctions(ServiceCtx context)
public ResultCode GetApplicationFunctions(ServiceCtx context)
{
MakeObject(context, new IApplicationFunctions());
return 0;
return ResultCode.Success;
}
[Command(1000)]
// GetDebugFunctions() -> object<nn::am::service::IDebugFunctions>
public long GetDebugFunctions(ServiceCtx context)
public ResultCode GetDebugFunctions(ServiceCtx context)
{
MakeObject(context, new IDebugFunctions());
return 0;
return ResultCode.Success;
}
}
}

View File

@ -7,11 +7,11 @@ namespace Ryujinx.HLE.HOS.Services.Am
[Command(0)]
// OpenApplicationProxy(u64, pid, handle<copy>) -> object<nn::am::service::IApplicationProxy>
public long OpenApplicationProxy(ServiceCtx context)
public ResultCode OpenApplicationProxy(ServiceCtx context)
{
MakeObject(context, new IApplicationProxy());
return 0;
return ResultCode.Success;
}
}
}

View File

@ -8,59 +8,59 @@ namespace Ryujinx.HLE.HOS.Services.Am
[Command(0)]
// SetExpectedMasterVolume(f32, f32)
public long SetExpectedMasterVolume(ServiceCtx context)
public ResultCode SetExpectedMasterVolume(ServiceCtx context)
{
float appletVolume = context.RequestData.ReadSingle();
float libraryAppletVolume = context.RequestData.ReadSingle();
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(1)]
// GetMainAppletExpectedMasterVolume() -> f32
public long GetMainAppletExpectedMasterVolume(ServiceCtx context)
public ResultCode GetMainAppletExpectedMasterVolume(ServiceCtx context)
{
context.ResponseData.Write(1f);
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(2)]
// GetLibraryAppletExpectedMasterVolume() -> f32
public long GetLibraryAppletExpectedMasterVolume(ServiceCtx context)
public ResultCode GetLibraryAppletExpectedMasterVolume(ServiceCtx context)
{
context.ResponseData.Write(1f);
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(3)]
// ChangeMainAppletMasterVolume(f32, u64)
public long ChangeMainAppletMasterVolume(ServiceCtx context)
public ResultCode ChangeMainAppletMasterVolume(ServiceCtx context)
{
float unknown0 = context.RequestData.ReadSingle();
long unknown1 = context.RequestData.ReadInt64();
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(4)]
// SetTransparentVolumeRate(f32)
public long SetTransparentVolumeRate(ServiceCtx context)
public ResultCode SetTransparentVolumeRate(ServiceCtx context)
{
float unknown0 = context.RequestData.ReadSingle();
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
}
}

View File

@ -4,8 +4,6 @@ using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Threading;
using System;
using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.HOS.Services.Am
{
class ICommonStateGetter : IpcService
@ -19,7 +17,7 @@ namespace Ryujinx.HLE.HOS.Services.Am
[Command(0)]
// GetEventHandle() -> handle<copy>
public long GetEventHandle(ServiceCtx context)
public ResultCode GetEventHandle(ServiceCtx context)
{
KEvent Event = context.Device.System.AppletState.MessageEvent;
@ -30,26 +28,26 @@ namespace Ryujinx.HLE.HOS.Services.Am
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
return 0;
return ResultCode.Success;
}
[Command(1)]
// ReceiveMessage() -> nn::am::AppletMessage
public long ReceiveMessage(ServiceCtx context)
public ResultCode ReceiveMessage(ServiceCtx context)
{
if (!context.Device.System.AppletState.TryDequeueMessage(out MessageInfo message))
{
return MakeError(ErrorModule.Am, AmErr.NoMessages);
return ResultCode.NoMessages;
}
context.ResponseData.Write((int)message);
return 0;
return ResultCode.Success;
}
[Command(5)]
// GetOperationMode() -> u8
public long GetOperationMode(ServiceCtx context)
public ResultCode GetOperationMode(ServiceCtx context)
{
OperationMode mode = context.Device.System.State.DockedMode
? OperationMode.Docked
@ -57,12 +55,12 @@ namespace Ryujinx.HLE.HOS.Services.Am
context.ResponseData.Write((byte)mode);
return 0;
return ResultCode.Success;
}
[Command(6)]
// GetPerformanceMode() -> u32
public long GetPerformanceMode(ServiceCtx context)
public ResultCode GetPerformanceMode(ServiceCtx context)
{
Apm.PerformanceMode mode = context.Device.System.State.DockedMode
? Apm.PerformanceMode.Docked
@ -70,42 +68,42 @@ namespace Ryujinx.HLE.HOS.Services.Am
context.ResponseData.Write((int)mode);
return 0;
return ResultCode.Success;
}
[Command(8)]
// GetBootMode() -> u8
public long GetBootMode(ServiceCtx context)
public ResultCode GetBootMode(ServiceCtx context)
{
context.ResponseData.Write((byte)0); //Unknown value.
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(9)]
// GetCurrentFocusState() -> u8
public long GetCurrentFocusState(ServiceCtx context)
public ResultCode GetCurrentFocusState(ServiceCtx context)
{
context.ResponseData.Write((byte)context.Device.System.AppletState.FocusState);
return 0;
return ResultCode.Success;
}
[Command(60)] // 3.0.0+
// GetDefaultDisplayResolution() -> (u32, u32)
public long GetDefaultDisplayResolution(ServiceCtx context)
public ResultCode GetDefaultDisplayResolution(ServiceCtx context)
{
context.ResponseData.Write(1280);
context.ResponseData.Write(720);
return 0;
return ResultCode.Success;
}
[Command(61)] // 3.0.0+
// GetDefaultDisplayResolutionChangeEvent() -> handle<copy>
public long GetDefaultDisplayResolutionChangeEvent(ServiceCtx context)
public ResultCode GetDefaultDisplayResolutionChangeEvent(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_displayResolutionChangeEvent.ReadableEvent, out int handle) != KernelResult.Success)
{
@ -116,7 +114,7 @@ namespace Ryujinx.HLE.HOS.Services.Am
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
}
}

View File

@ -18,16 +18,16 @@ namespace Ryujinx.HLE.HOS.Services.Am
[Command(10)]
// RequestToGetForeground()
public long RequestToGetForeground(ServiceCtx context)
public ResultCode RequestToGetForeground(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(21)]
// GetPopFromGeneralChannelEvent() -> handle<copy>
public long GetPopFromGeneralChannelEvent(ServiceCtx context)
public ResultCode GetPopFromGeneralChannelEvent(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_channelEvent.ReadableEvent, out int handle) != KernelResult.Success)
{
@ -38,7 +38,7 @@ namespace Ryujinx.HLE.HOS.Services.Am
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
}
}

View File

@ -17,7 +17,7 @@ namespace Ryujinx.HLE.HOS.Services.Am
[Command(0)]
// GetAppletStateChangedEvent() -> handle<copy>
public long GetAppletStateChangedEvent(ServiceCtx context)
public ResultCode GetAppletStateChangedEvent(ServiceCtx context)
{
_stateChangedEvent.ReadableEvent.Signal();
@ -30,43 +30,43 @@ namespace Ryujinx.HLE.HOS.Services.Am
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(10)]
// Start()
public long Start(ServiceCtx context)
public ResultCode Start(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(30)]
// GetResult()
public long GetResult(ServiceCtx context)
public ResultCode GetResult(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(100)]
// PushInData(object<nn::am::service::IStorage>)
public long PushInData(ServiceCtx context)
public ResultCode PushInData(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(101)]
// PopOutData() -> object<nn::am::service::IStorage>
public long PopOutData(ServiceCtx context)
public ResultCode PopOutData(ServiceCtx context)
{
MakeObject(context, new IStorage(StorageHelper.MakeLaunchParams()));
return 0;
return ResultCode.Success;
}
}
}

View File

@ -6,22 +6,22 @@ namespace Ryujinx.HLE.HOS.Services.Am
[Command(0)]
// CreateLibraryApplet(u32, u32) -> object<nn::am::service::ILibraryAppletAccessor>
public long CreateLibraryApplet(ServiceCtx context)
public ResultCode CreateLibraryApplet(ServiceCtx context)
{
MakeObject(context, new ILibraryAppletAccessor(context.Device.System));
return 0;
return ResultCode.Success;
}
[Command(10)]
// CreateStorage(u64) -> object<nn::am::service::IStorage>
public long CreateStorage(ServiceCtx context)
public ResultCode CreateStorage(ServiceCtx context)
{
long size = context.RequestData.ReadInt64();
MakeObject(context, new IStorage(new byte[size]));
return 0;
return ResultCode.Success;
}
}
}

View File

@ -22,34 +22,34 @@ namespace Ryujinx.HLE.HOS.Services.Am
[Command(0)]
// Exit()
public long Exit(ServiceCtx context)
public ResultCode Exit(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(1)]
// LockExit()
public long LockExit(ServiceCtx context)
public ResultCode LockExit(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(2)]
// UnlockExit()
public long UnlockExit(ServiceCtx context)
public ResultCode UnlockExit(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(9)]
// GetLibraryAppletLaunchableEvent() -> handle<copy>
public long GetLibraryAppletLaunchableEvent(ServiceCtx context)
public ResultCode GetLibraryAppletLaunchableEvent(ServiceCtx context)
{
_libraryAppletLaunchableEvent.ReadableEvent.Signal();
@ -62,45 +62,45 @@ namespace Ryujinx.HLE.HOS.Services.Am
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(10)]
// SetScreenShotPermission(u32)
public long SetScreenShotPermission(ServiceCtx context)
public ResultCode SetScreenShotPermission(ServiceCtx context)
{
bool enable = context.RequestData.ReadByte() != 0;
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(11)]
// SetOperationModeChangedNotification(b8)
public long SetOperationModeChangedNotification(ServiceCtx context)
public ResultCode SetOperationModeChangedNotification(ServiceCtx context)
{
bool enable = context.RequestData.ReadByte() != 0;
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(12)]
// SetPerformanceModeChangedNotification(b8)
public long SetPerformanceModeChangedNotification(ServiceCtx context)
public ResultCode SetPerformanceModeChangedNotification(ServiceCtx context)
{
bool enable = context.RequestData.ReadByte() != 0;
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(13)]
// SetFocusHandlingMode(b8, b8, b8)
public long SetFocusHandlingMode(ServiceCtx context)
public ResultCode SetFocusHandlingMode(ServiceCtx context)
{
bool flag1 = context.RequestData.ReadByte() != 0;
bool flag2 = context.RequestData.ReadByte() != 0;
@ -108,77 +108,77 @@ namespace Ryujinx.HLE.HOS.Services.Am
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(14)]
// SetRestartMessageEnabled(b8)
public long SetRestartMessageEnabled(ServiceCtx context)
public ResultCode SetRestartMessageEnabled(ServiceCtx context)
{
bool enable = context.RequestData.ReadByte() != 0;
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(16)] // 2.0.0+
// SetOutOfFocusSuspendingEnabled(b8)
public long SetOutOfFocusSuspendingEnabled(ServiceCtx context)
public ResultCode SetOutOfFocusSuspendingEnabled(ServiceCtx context)
{
bool enable = context.RequestData.ReadByte() != 0;
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(19)] // 3.0.0+
public long SetScreenShotImageOrientation(ServiceCtx context)
public ResultCode SetScreenShotImageOrientation(ServiceCtx context)
{
int orientation = context.RequestData.ReadInt32();
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(50)]
// SetHandlesRequestToDisplay(b8)
public long SetHandlesRequestToDisplay(ServiceCtx context)
public ResultCode SetHandlesRequestToDisplay(ServiceCtx context)
{
bool enable = context.RequestData.ReadByte() != 0;
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
[Command(62)]
// SetIdleTimeDetectionExtension(u32)
public long SetIdleTimeDetectionExtension(ServiceCtx context)
public ResultCode SetIdleTimeDetectionExtension(ServiceCtx context)
{
_idleTimeDetectionExtension = context.RequestData.ReadInt32();
Logger.PrintStub(LogClass.ServiceAm, new { _idleTimeDetectionExtension });
return 0;
return ResultCode.Success;
}
[Command(63)]
// GetIdleTimeDetectionExtension() -> u32
public long GetIdleTimeDetectionExtension(ServiceCtx context)
public ResultCode GetIdleTimeDetectionExtension(ServiceCtx context)
{
context.ResponseData.Write(_idleTimeDetectionExtension);
Logger.PrintStub(LogClass.ServiceAm, new { _idleTimeDetectionExtension });
return 0;
return ResultCode.Success;
}
[Command(91)] // 6.0.0+
// GetAccumulatedSuspendedTickChangedEvent() -> handle<copy>
public long GetAccumulatedSuspendedTickChangedEvent(ServiceCtx context)
public ResultCode GetAccumulatedSuspendedTickChangedEvent(ServiceCtx context)
{
if (_accumulatedSuspendedTickChangedEventHandle == 0)
{
@ -194,7 +194,7 @@ namespace Ryujinx.HLE.HOS.Services.Am
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_accumulatedSuspendedTickChangedEventHandle);
return 0;
return ResultCode.Success;
}
}
}

View File

@ -11,11 +11,11 @@ namespace Ryujinx.HLE.HOS.Services.Am
[Command(0)]
// Open() -> object<nn::am::service::IStorageAccessor>
public long Open(ServiceCtx context)
public ResultCode Open(ServiceCtx context)
{
MakeObject(context, new IStorageAccessor(this));
return 0;
return ResultCode.Success;
}
}
}

View File

@ -13,16 +13,16 @@ namespace Ryujinx.HLE.HOS.Services.Am
[Command(0)]
// GetSize() -> u64
public long GetSize(ServiceCtx context)
public ResultCode GetSize(ServiceCtx context)
{
context.ResponseData.Write((long)_storage.Data.Length);
return 0;
return ResultCode.Success;
}
[Command(10)]
// Write(u64, buffer<bytes, 0x21>)
public long Write(ServiceCtx context)
public ResultCode Write(ServiceCtx context)
{
// TODO: Error conditions.
long writePosition = context.RequestData.ReadInt64();
@ -43,12 +43,12 @@ namespace Ryujinx.HLE.HOS.Services.Am
Buffer.BlockCopy(data, 0, _storage.Data, (int)writePosition, (int)size);
}
return 0;
return ResultCode.Success;
}
[Command(11)]
// Read(u64) -> buffer<bytes, 0x22>
public long Read(ServiceCtx context)
public ResultCode Read(ServiceCtx context)
{
// TODO: Error conditions.
long readPosition = context.RequestData.ReadInt64();
@ -70,7 +70,7 @@ namespace Ryujinx.HLE.HOS.Services.Am
context.Memory.WriteBytes(position, data);
return 0;
return ResultCode.Success;
}
}
}

View File

@ -6,92 +6,92 @@ namespace Ryujinx.HLE.HOS.Services.Am
[Command(0)]
// GetCommonStateGetter() -> object<nn::am::service::ICommonStateGetter>
public long GetCommonStateGetter(ServiceCtx context)
public ResultCode GetCommonStateGetter(ServiceCtx context)
{
MakeObject(context, new ICommonStateGetter(context.Device.System));
return 0;
return ResultCode.Success;
}
[Command(1)]
// GetSelfController() -> object<nn::am::service::ISelfController>
public long GetSelfController(ServiceCtx context)
public ResultCode GetSelfController(ServiceCtx context)
{
MakeObject(context, new ISelfController(context.Device.System));
return 0;
return ResultCode.Success;
}
[Command(2)]
// GetWindowController() -> object<nn::am::service::IWindowController>
public long GetWindowController(ServiceCtx context)
public ResultCode GetWindowController(ServiceCtx context)
{
MakeObject(context, new IWindowController());
return 0;
return ResultCode.Success;
}
[Command(3)]
// GetAudioController() -> object<nn::am::service::IAudioController>
public long GetAudioController(ServiceCtx context)
public ResultCode GetAudioController(ServiceCtx context)
{
MakeObject(context, new IAudioController());
return 0;
return ResultCode.Success;
}
[Command(4)]
// GetDisplayController() -> object<nn::am::service::IDisplayController>
public long GetDisplayController(ServiceCtx context)
public ResultCode GetDisplayController(ServiceCtx context)
{
MakeObject(context, new IDisplayController());
return 0;
return ResultCode.Success;
}
[Command(11)]
// GetLibraryAppletCreator() -> object<nn::am::service::ILibraryAppletCreator>
public long GetLibraryAppletCreator(ServiceCtx context)
public ResultCode GetLibraryAppletCreator(ServiceCtx context)
{
MakeObject(context, new ILibraryAppletCreator());
return 0;
return ResultCode.Success;
}
[Command(20)]
// GetHomeMenuFunctions() -> object<nn::am::service::IHomeMenuFunctions>
public long GetHomeMenuFunctions(ServiceCtx context)
public ResultCode GetHomeMenuFunctions(ServiceCtx context)
{
MakeObject(context, new IHomeMenuFunctions(context.Device.System));
return 0;
return ResultCode.Success;
}
[Command(21)]
// GetGlobalStateController() -> object<nn::am::service::IGlobalStateController>
public long GetGlobalStateController(ServiceCtx context)
public ResultCode GetGlobalStateController(ServiceCtx context)
{
MakeObject(context, new IGlobalStateController());
return 0;
return ResultCode.Success;
}
[Command(22)]
// GetApplicationCreator() -> object<nn::am::service::IApplicationCreator>
public long GetApplicationCreator(ServiceCtx context)
public ResultCode GetApplicationCreator(ServiceCtx context)
{
MakeObject(context, new IApplicationCreator());
return 0;
return ResultCode.Success;
}
[Command(1000)]
// GetDebugFunctions() -> object<nn::am::service::IDebugFunctions>
public long GetDebugFunctions(ServiceCtx context)
public ResultCode GetDebugFunctions(ServiceCtx context)
{
MakeObject(context, new IDebugFunctions());
return 0;
return ResultCode.Success;
}
}
}

View File

@ -8,22 +8,22 @@ namespace Ryujinx.HLE.HOS.Services.Am
[Command(1)]
// GetAppletResourceUserId() -> nn::applet::AppletResourceUserId
public long GetAppletResourceUserId(ServiceCtx context)
public ResultCode GetAppletResourceUserId(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
context.ResponseData.Write(0L);
return 0;
return ResultCode.Success;
}
[Command(10)]
// AcquireForegroundRights()
public long AcquireForegroundRights(ServiceCtx context)
public ResultCode AcquireForegroundRights(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
return 0;
return ResultCode.Success;
}
}
}

View File

@ -0,0 +1,12 @@
namespace Ryujinx.HLE.HOS.Services.Am
{
enum ResultCode
{
ModuleId = 128,
ErrorCodeShift = 9,
Success = 0,
NoMessages = (3 << ErrorCodeShift) | ModuleId
}
}

View File

@ -8,11 +8,11 @@ namespace Ryujinx.HLE.HOS.Services.Apm
[Command(0)]
// OpenSession() -> object<nn::apm::ISession>
public long OpenSession(ServiceCtx context)
public ResultCode OpenSession(ServiceCtx context)
{
MakeObject(context, new ISession());
return 0;
return ResultCode.Success;
}
}
}

View File

@ -8,17 +8,17 @@ namespace Ryujinx.HLE.HOS.Services.Apm
[Command(0)]
// SetPerformanceConfiguration(nn::apm::PerformanceMode, nn::apm::PerformanceConfiguration)
public long SetPerformanceConfiguration(ServiceCtx context)
public ResultCode SetPerformanceConfiguration(ServiceCtx context)
{
PerformanceMode perfMode = (PerformanceMode)context.RequestData.ReadInt32();
PerformanceConfiguration perfConfig = (PerformanceConfiguration)context.RequestData.ReadInt32();
return 0;
return ResultCode.Success;
}
[Command(1)]
// GetPerformanceConfiguration(nn::apm::PerformanceMode) -> nn::apm::PerformanceConfiguration
public long GetPerformanceConfiguration(ServiceCtx context)
public ResultCode GetPerformanceConfiguration(ServiceCtx context)
{
PerformanceMode perfMode = (PerformanceMode)context.RequestData.ReadInt32();
@ -26,7 +26,7 @@ namespace Ryujinx.HLE.HOS.Services.Apm
Logger.PrintStub(LogClass.ServiceApm);
return 0;
return ResultCode.Success;
}
}
}

View File

@ -15,4 +15,4 @@
PerformanceConfiguration11 = 0x92220007,
PerformanceConfiguration12 = 0x92220008
}
}
}

View File

@ -5,4 +5,4 @@
Handheld = 0,
Docked = 1
}
}
}

View File

@ -1,10 +0,0 @@
namespace Ryujinx.HLE.HOS.Services.Aud
{
static class AudErr
{
public const int DeviceNotFound = 1;
public const int UnsupportedRevision = 2;
public const int UnsupportedSampleRate = 3;
public const int OpusInvalidInput = 6;
}
}

View File

@ -22,41 +22,41 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
[Command(0)]
// GetAudioOutState() -> u32 state
public long GetAudioOutState(ServiceCtx context)
public ResultCode GetAudioOutState(ServiceCtx context)
{
context.ResponseData.Write((int)_audioOut.GetState(_track));
return 0;
return ResultCode.Success;
}
[Command(1)]
// StartAudioOut()
public long StartAudioOut(ServiceCtx context)
public ResultCode StartAudioOut(ServiceCtx context)
{
_audioOut.Start(_track);
return 0;
return ResultCode.Success;
}
[Command(2)]
// StopAudioOut()
public long StopAudioOut(ServiceCtx context)
public ResultCode StopAudioOut(ServiceCtx context)
{
_audioOut.Stop(_track);
return 0;
return ResultCode.Success;
}
[Command(3)]
// AppendAudioOutBuffer(u64 tag, buffer<nn::audio::AudioOutBuffer, 5>)
public long AppendAudioOutBuffer(ServiceCtx context)
public ResultCode AppendAudioOutBuffer(ServiceCtx context)
{
return AppendAudioOutBufferImpl(context, context.Request.SendBuff[0].Position);
}
[Command(4)]
// RegisterBufferEvent() -> handle<copy>
public long RegisterBufferEvent(ServiceCtx context)
public ResultCode RegisterBufferEvent(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_releaseEvent.ReadableEvent, out int handle) != KernelResult.Success)
{
@ -65,12 +65,12 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
return 0;
return ResultCode.Success;
}
[Command(5)]
// GetReleasedAudioOutBuffer() -> (u32 count, buffer<nn::audio::AudioOutBuffer, 6>)
public long GetReleasedAudioOutBuffer(ServiceCtx context)
public ResultCode GetReleasedAudioOutBuffer(ServiceCtx context)
{
long position = context.Request.ReceiveBuff[0].Position;
long size = context.Request.ReceiveBuff[0].Size;
@ -80,7 +80,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
[Command(6)]
// ContainsAudioOutBuffer(u64 tag) -> b8
public long ContainsAudioOutBuffer(ServiceCtx context)
public ResultCode ContainsAudioOutBuffer(ServiceCtx context)
{
long tag = context.RequestData.ReadInt64();
@ -91,14 +91,14 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
[Command(7)] // 3.0.0+
// AppendAudioOutBufferAuto(u64 tag, buffer<nn::audio::AudioOutBuffer, 0x21>)
public long AppendAudioOutBufferAuto(ServiceCtx context)
public ResultCode AppendAudioOutBufferAuto(ServiceCtx context)
{
(long position, long size) = context.Request.GetBufferType0x21();
return AppendAudioOutBufferImpl(context, position);
}
public long AppendAudioOutBufferImpl(ServiceCtx context, long position)
public ResultCode AppendAudioOutBufferImpl(ServiceCtx context, long position)
{
long tag = context.RequestData.ReadInt64();
@ -112,19 +112,19 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
_audioOut.AppendBuffer(_track, tag, buffer);
return 0;
return ResultCode.Success;
}
[Command(8)] // 3.0.0+
// GetReleasedAudioOutBufferAuto() -> (u32 count, buffer<nn::audio::AudioOutBuffer, 0x22>)
public long GetReleasedAudioOutBufferAuto(ServiceCtx context)
public ResultCode GetReleasedAudioOutBufferAuto(ServiceCtx context)
{
(long position, long size) = context.Request.GetBufferType0x22();
return GetReleasedAudioOutBufferImpl(context, position, size);
}
public long GetReleasedAudioOutBufferImpl(ServiceCtx context, long position, long size)
public ResultCode GetReleasedAudioOutBufferImpl(ServiceCtx context, long position, long size)
{
uint count = (uint)((ulong)size >> 3);
@ -144,7 +144,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
context.ResponseData.Write(releasedBuffers.Length);
return 0;
return ResultCode.Success;
}
public void Dispose()

View File

@ -5,4 +5,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
public const int HostSampleRate = 48000;
public const int HostChannelsCount = 2;
}
}
}

View File

@ -13,4 +13,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
public short A1;
public short A2;
}
}
}

View File

@ -66,40 +66,40 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
[Command(0)]
// GetSampleRate() -> u32
public long GetSampleRate(ServiceCtx context)
public ResultCode GetSampleRate(ServiceCtx context)
{
context.ResponseData.Write(_params.SampleRate);
return 0;
return ResultCode.Success;
}
[Command(1)]
// GetSampleCount() -> u32
public long GetSampleCount(ServiceCtx context)
public ResultCode GetSampleCount(ServiceCtx context)
{
context.ResponseData.Write(_params.SampleCount);
return 0;
return ResultCode.Success;
}
[Command(2)]
// GetMixBufferCount() -> u32
public long GetMixBufferCount(ServiceCtx context)
public ResultCode GetMixBufferCount(ServiceCtx context)
{
context.ResponseData.Write(_params.MixCount);
return 0;
return ResultCode.Success;
}
[Command(3)]
// GetState() -> u32
private long GetState(ServiceCtx context)
private ResultCode GetState(ServiceCtx context)
{
context.ResponseData.Write((int)_playState);
Logger.PrintStub(LogClass.ServiceAudio, new { State = Enum.GetName(typeof(PlayState), _playState) });
return 0;
return ResultCode.Success;
}
private void AudioCallback()
@ -131,7 +131,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
[Command(4)]
// RequestUpdateAudioRenderer(buffer<nn::audio::detail::AudioRendererUpdateDataHeader, 5>)
// -> (buffer<nn::audio::detail::AudioRendererUpdateDataHeader, 6>, buffer<nn::audio::detail::AudioRendererUpdateDataHeader, 6>)
public long RequestUpdateAudioRenderer(ServiceCtx context)
public ResultCode RequestUpdateAudioRenderer(ServiceCtx context)
{
long outputPosition = context.Request.ReceiveBuff[0].Position;
long outputSize = context.Request.ReceiveBuff[0].Size;
@ -234,34 +234,34 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
writer.Write(voice.OutStatus);
}
return 0;
return ResultCode.Success;
}
[Command(5)]
// Start()
public long StartAudioRenderer(ServiceCtx context)
public ResultCode StartAudioRenderer(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAudio);
_playState = PlayState.Playing;
return 0;
return ResultCode.Success;
}
[Command(6)]
// Stop()
public long StopAudioRenderer(ServiceCtx context)
public ResultCode StopAudioRenderer(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAudio);
_playState = PlayState.Stopped;
return 0;
return ResultCode.Success;
}
[Command(7)]
// QuerySystemEvent() -> handle<copy, event>
public long QuerySystemEvent(ServiceCtx context)
public ResultCode QuerySystemEvent(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_updateEvent.ReadableEvent, out int handle) != KernelResult.Success)
{
@ -270,7 +270,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
return 0;
return ResultCode.Success;
}
private AdpcmDecoderContext GetAdpcmDecoderContext(long position, long size)

View File

@ -9,4 +9,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
OutStatus.State = MemoryPoolState.Detached;
}
}
}
}

View File

@ -11,4 +11,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
public int Unknown14;
public long Unknown18;
}
}
}

View File

@ -9,4 +9,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
public int Unknown14;
public long Unknown18;
}
}
}

View File

@ -10,4 +10,4 @@
Attached = 5,
Released = 6
}
}
}

View File

@ -6,4 +6,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
Stopped = 1,
Paused = 2
}
}
}

View File

@ -19,4 +19,4 @@
public int Unknown38;
public int TotalSize;
}
}
}

View File

@ -7,4 +7,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
{
// ???
}
}
}

View File

@ -196,4 +196,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
_bufferReload = true;
}
}
}
}

View File

@ -46,4 +46,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
public WaveBuffer WaveBuffer2;
public WaveBuffer WaveBuffer3;
}
}
}

View File

@ -9,4 +9,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
public int PlayedWaveBuffersCount;
public int VoiceDropsCount; //?
}
}
}

View File

@ -17,4 +17,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
public long AdpcmLoopContextSize;
public long Unknown30;
}
}
}

View File

@ -19,4 +19,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud
public int Unknown2C;
public int Revision;
}
}
}

View File

@ -22,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(0)]
// ListAudioDeviceName() -> (u32, buffer<bytes, 6>)
public long ListAudioDeviceName(ServiceCtx context)
public ResultCode ListAudioDeviceName(ServiceCtx context)
{
string[] deviceNames = SystemStateMgr.AudioOutputs;
@ -49,12 +49,12 @@ namespace Ryujinx.HLE.HOS.Services.Aud
position += buffer.Length;
}
return 0;
return ResultCode.Success;
}
[Command(1)]
// SetAudioDeviceOutputVolume(u32, buffer<bytes, 5>)
public long SetAudioDeviceOutputVolume(ServiceCtx context)
public ResultCode SetAudioDeviceOutputVolume(ServiceCtx context)
{
float volume = context.RequestData.ReadSingle();
@ -67,12 +67,12 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintStub(LogClass.ServiceAudio);
return 0;
return ResultCode.Success;
}
[Command(3)]
// GetActiveAudioDeviceName() -> buffer<bytes, 6>
public long GetActiveAudioDeviceName(ServiceCtx context)
public ResultCode GetActiveAudioDeviceName(ServiceCtx context)
{
string name = context.Device.System.State.ActiveAudioOutput;
@ -90,12 +90,12 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintError(LogClass.ServiceAudio, $"Output buffer size {size} too small!");
}
return 0;
return ResultCode.Success;
}
[Command(4)]
// QueryAudioDeviceSystemEvent() -> handle<copy, event>
public long QueryAudioDeviceSystemEvent(ServiceCtx context)
public ResultCode QueryAudioDeviceSystemEvent(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_systemEvent.ReadableEvent, out int handle) != KernelResult.Success)
{
@ -106,23 +106,23 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintStub(LogClass.ServiceAudio);
return 0;
return ResultCode.Success;
}
[Command(5)]
// GetActiveChannelCount() -> u32
public long GetActiveChannelCount(ServiceCtx context)
public ResultCode GetActiveChannelCount(ServiceCtx context)
{
context.ResponseData.Write(2);
Logger.PrintStub(LogClass.ServiceAudio);
return 0;
return ResultCode.Success;
}
[Command(6)]
// ListAudioDeviceNameAuto() -> (u32, buffer<bytes, 0x22>)
public long ListAudioDeviceNameAuto(ServiceCtx context)
public ResultCode ListAudioDeviceNameAuto(ServiceCtx context)
{
string[] deviceNames = SystemStateMgr.AudioOutputs;
@ -148,12 +148,12 @@ namespace Ryujinx.HLE.HOS.Services.Aud
position += buffer.Length;
}
return 0;
return ResultCode.Success;
}
[Command(7)]
// SetAudioDeviceOutputVolumeAuto(u32, buffer<bytes, 0x21>)
public long SetAudioDeviceOutputVolumeAuto(ServiceCtx context)
public ResultCode SetAudioDeviceOutputVolumeAuto(ServiceCtx context)
{
float volume = context.RequestData.ReadSingle();
@ -165,23 +165,23 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintStub(LogClass.ServiceAudio);
return 0;
return ResultCode.Success;
}
[Command(8)]
// GetAudioDeviceOutputVolumeAuto(buffer<bytes, 0x21>) -> u32
public long GetAudioDeviceOutputVolumeAuto(ServiceCtx context)
public ResultCode GetAudioDeviceOutputVolumeAuto(ServiceCtx context)
{
context.ResponseData.Write(1f);
Logger.PrintStub(LogClass.ServiceAudio);
return 0;
return ResultCode.Success;
}
[Command(10)]
// GetActiveAudioDeviceNameAuto() -> buffer<bytes, 0x22>
public long GetActiveAudioDeviceNameAuto(ServiceCtx context)
public ResultCode GetActiveAudioDeviceNameAuto(ServiceCtx context)
{
string name = context.Device.System.State.ActiveAudioOutput;
@ -198,12 +198,12 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintError(LogClass.ServiceAudio, $"Output buffer size {size} too small!");
}
return 0;
return ResultCode.Success;
}
[Command(11)]
// QueryAudioDeviceInputEvent() -> handle<copy, event>
public long QueryAudioDeviceInputEvent(ServiceCtx context)
public ResultCode QueryAudioDeviceInputEvent(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_systemEvent.ReadableEvent, out int handle) != KernelResult.Success)
{
@ -214,12 +214,12 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintStub(LogClass.ServiceAudio);
return 0;
return ResultCode.Success;
}
[Command(12)]
// QueryAudioDeviceOutputEvent() -> handle<copy, event>
public long QueryAudioDeviceOutputEvent(ServiceCtx context)
public ResultCode QueryAudioDeviceOutputEvent(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_systemEvent.ReadableEvent, out int handle) != KernelResult.Success)
{
@ -230,7 +230,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintStub(LogClass.ServiceAudio);
return 0;
return ResultCode.Success;
}
}
}

View File

@ -5,8 +5,6 @@ using Ryujinx.HLE.HOS.Kernel.Threading;
using Ryujinx.HLE.HOS.Services.Aud.AudioOut;
using System.Text;
using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.HOS.Services.Aud
{
[Service("audout:u")]
@ -20,7 +18,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(0)]
// ListAudioOuts() -> (u32 count, buffer<bytes, 6>)
public long ListAudioOuts(ServiceCtx context)
public ResultCode ListAudioOuts(ServiceCtx context)
{
return ListAudioOutsImpl(
context,
@ -31,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(1)]
// OpenAudioOut(u32 sample_rate, u16 unused, u16 channel_count, nn::applet::AppletResourceUserId, pid, handle<copy, process>, buffer<bytes, 5> name_in)
// -> (u32 sample_rate, u32 channel_count, u32 pcm_format, u32, object<nn::audio::detail::IAudioOut>, buffer<bytes, 6> name_out)
public long OpenAudioOut(ServiceCtx context)
public ResultCode OpenAudioOut(ServiceCtx context)
{
return OpenAudioOutImpl(
context,
@ -43,7 +41,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(2)] // 3.0.0+
// ListAudioOutsAuto() -> (u32 count, buffer<bytes, 0x22>)
public long ListAudioOutsAuto(ServiceCtx context)
public ResultCode ListAudioOutsAuto(ServiceCtx context)
{
(long recvPosition, long recvSize) = context.Request.GetBufferType0x22();
@ -53,7 +51,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(3)] // 3.0.0+
// OpenAudioOutAuto(u32 sample_rate, u16 unused, u16 channel_count, nn::applet::AppletResourceUserId, pid, handle<copy, process>, buffer<bytes, 0x21>)
// -> (u32 sample_rate, u32 channel_count, u32 pcm_format, u32, object<nn::audio::detail::IAudioOut>, buffer<bytes, 0x22> name_out)
public long OpenAudioOutAuto(ServiceCtx context)
public ResultCode OpenAudioOutAuto(ServiceCtx context)
{
(long sendPosition, long sendSize) = context.Request.GetBufferType0x21();
(long recvPosition, long recvSize) = context.Request.GetBufferType0x22();
@ -66,7 +64,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
recvSize);
}
private long ListAudioOutsImpl(ServiceCtx context, long position, long size)
private ResultCode ListAudioOutsImpl(ServiceCtx context, long position, long size)
{
int nameCount = 0;
@ -85,10 +83,10 @@ namespace Ryujinx.HLE.HOS.Services.Aud
context.ResponseData.Write(nameCount);
return 0;
return ResultCode.Success;
}
private long OpenAudioOutImpl(ServiceCtx context, long sendPosition, long sendSize, long receivePosition, long receiveSize)
private ResultCode OpenAudioOutImpl(ServiceCtx context, long sendPosition, long sendSize, long receivePosition, long receiveSize)
{
string deviceName = MemoryHelper.ReadAsciiString(
context.Memory,
@ -104,7 +102,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
{
Logger.PrintWarning(LogClass.Audio, "Invalid device name!");
return MakeError(ErrorModule.Audio, AudErr.DeviceNotFound);
return ResultCode.DeviceNotFound;
}
byte[] deviceNameBuffer = Encoding.ASCII.GetBytes(deviceName + "\0");
@ -130,7 +128,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
{
Logger.PrintWarning(LogClass.Audio, "Invalid sample rate!");
return MakeError(ErrorModule.Audio, AudErr.UnsupportedSampleRate);
return ResultCode.UnsupportedSampleRate;
}
channels = (ushort)channels;
@ -158,7 +156,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
context.ResponseData.Write((int)SampleFormat.PcmInt16);
context.ResponseData.Write((int)PlaybackState.Stopped);
return 0;
return ResultCode.Success;
}
}
}

View File

@ -3,8 +3,6 @@ using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Services.Aud.AudioRenderer;
using Ryujinx.HLE.Utilities;
using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.HOS.Services.Aud
{
[Service("audren:u")]
@ -24,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(0)]
// OpenAudioRenderer(nn::audio::detail::AudioRendererParameterInternal, u64, nn::applet::AppletResourceUserId, pid, handle<copy>, handle<copy>)
// -> object<nn::audio::detail::IAudioRenderer>
public long OpenAudioRenderer(ServiceCtx context)
public ResultCode OpenAudioRenderer(ServiceCtx context)
{
IAalOutput audioOut = context.Device.AudioOut;
@ -36,12 +34,12 @@ namespace Ryujinx.HLE.HOS.Services.Aud
audioOut,
Params));
return 0;
return ResultCode.Success;
}
[Command(1)]
// GetWorkBufferSize(nn::audio::detail::AudioRendererParameterInternal) -> u64
public long GetAudioRendererWorkBufferSize(ServiceCtx context)
public ResultCode GetAudioRendererWorkBufferSize(ServiceCtx context)
{
AudioRendererParameter Params = GetAudioRendererParameter(context);
@ -111,7 +109,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintDebug(LogClass.ServiceAudio, $"WorkBufferSize is 0x{size:x16}.");
return 0;
return ResultCode.Success;
}
else
{
@ -119,7 +117,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintWarning(LogClass.ServiceAudio, $"Library Revision 0x{Params.Revision:x8} is not supported!");
return MakeError(ErrorModule.Audio, AudErr.UnsupportedRevision);
return ResultCode.UnsupportedRevision;
}
}
@ -170,18 +168,18 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(2)]
// GetAudioDeviceService(nn::applet::AppletResourceUserId) -> object<nn::audio::detail::IAudioDevice>
public long GetAudioDeviceService(ServiceCtx context)
public ResultCode GetAudioDeviceService(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
MakeObject(context, new IAudioDevice(context.Device.System));
return 0;
return ResultCode.Success;
}
[Command(4)] // 4.0.0+
// GetAudioDeviceServiceWithRevisionInfo(nn::applet::AppletResourceUserId, u32) -> object<nn::audio::detail::IAudioDevice>
private long GetAudioDeviceServiceWithRevisionInfo(ServiceCtx context)
private ResultCode GetAudioDeviceServiceWithRevisionInfo(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
int revisionInfo = context.RequestData.ReadInt32();

View File

@ -1,7 +1,5 @@
using Concentus.Structs;
using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.HOS.Services.Aud
{
class IHardwareOpusDecoder : IpcService
@ -23,14 +21,14 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(0)]
// DecodeInterleaved(buffer<unknown, 5>) -> (u32, u32, buffer<unknown, 6>)
public long DecodeInterleaved(ServiceCtx context)
public ResultCode DecodeInterleaved(ServiceCtx context)
{
long inPosition = context.Request.SendBuff[0].Position;
long inSize = context.Request.SendBuff[0].Size;
if (inSize < 8)
{
return MakeError(ErrorModule.Audio, AudErr.OpusInvalidInput);
return ResultCode.OpusInvalidInput;
}
long outPosition = context.Request.ReceiveBuff[0].Position;
@ -45,7 +43,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
if ((uint)processed > (ulong)inSize)
{
return MakeError(ErrorModule.Audio, AudErr.OpusInvalidInput);
return ResultCode.OpusInvalidInput;
}
short[] pcm = new short[outSize / 2];
@ -64,14 +62,14 @@ namespace Ryujinx.HLE.HOS.Services.Aud
context.ResponseData.Write(processed);
context.ResponseData.Write(samples);
return 0;
return ResultCode.Success;
}
[Command(4)]
// DecodeInterleavedWithPerf(buffer<unknown, 5>) -> (u32, u32, u64, buffer<unknown, 0x46>)
public long DecodeInterleavedWithPerf(ServiceCtx context)
public ResultCode DecodeInterleavedWithPerf(ServiceCtx context)
{
long result = DecodeInterleaved(context);
ResultCode result = DecodeInterleaved(context);
// TODO: Figure out what this value is.
// According to switchbrew, it is now used.

View File

@ -7,19 +7,19 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(0)]
// Initialize(bytes<8, 4>, u32, handle<copy>) -> object<nn::codec::detail::IHardwareOpusDecoder>
public long Initialize(ServiceCtx context)
public ResultCode Initialize(ServiceCtx context)
{
int sampleRate = context.RequestData.ReadInt32();
int channelsCount = context.RequestData.ReadInt32();
MakeObject(context, new IHardwareOpusDecoder(sampleRate, channelsCount));
return 0;
return ResultCode.Success;
}
[Command(1)]
// GetWorkBufferSize(bytes<8, 4>) -> u32
public long GetWorkBufferSize(ServiceCtx context)
public ResultCode GetWorkBufferSize(ServiceCtx context)
{
// Note: The sample rate is ignored because it is fixed to 48KHz.
int sampleRate = context.RequestData.ReadInt32();
@ -27,7 +27,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
context.ResponseData.Write(GetOpusDecoderSize(channelsCount));
return 0;
return ResultCode.Success;
}
private static int GetOpusDecoderSize(int channelsCount)

View File

@ -0,0 +1,15 @@
namespace Ryujinx.HLE.HOS.Services.Aud
{
enum ResultCode
{
ModuleId = 153,
ErrorCodeShift = 9,
Success = 0,
DeviceNotFound = (1 << ErrorCodeShift) | ModuleId,
UnsupportedRevision = (2 << ErrorCodeShift) | ModuleId,
UnsupportedSampleRate = (3 << ErrorCodeShift) | ModuleId,
OpusInvalidInput = (6 << ErrorCodeShift) | ModuleId
}
}

View File

@ -10,24 +10,24 @@ namespace Ryujinx.HLE.HOS.Services.Bcat
[Command(0)]
// CreateBcatService(u64, pid) -> object<nn::bcat::detail::ipc::IBcatService>
public long CreateBcatService(ServiceCtx context)
public ResultCode CreateBcatService(ServiceCtx context)
{
long id = context.RequestData.ReadInt64();
MakeObject(context, new IBcatService());
return 0;
return ResultCode.Success;
}
[Command(1)]
// CreateDeliveryCacheStorageService(u64, pid) -> object<nn::bcat::detail::ipc::IDeliveryCacheStorageService>
public long CreateDeliveryCacheStorageService(ServiceCtx context)
public ResultCode CreateDeliveryCacheStorageService(ServiceCtx context)
{
long id = context.RequestData.ReadInt64();
MakeObject(context, new IDeliveryCacheStorageService());
return 0;
return ResultCode.Success;
}
}
}
}

View File

@ -4,4 +4,4 @@
{
AtMark = 0x40047307
}
}
}

View File

@ -114,12 +114,12 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
return errno;
}
private long WriteWinSock2Error(ServiceCtx context, WsaError errorCode)
private ResultCode WriteWinSock2Error(ServiceCtx context, WsaError errorCode)
{
return WriteBsdResult(context, -1, ConvertError(errorCode));
}
private long WriteBsdResult(ServiceCtx context, int result, LinuxError errorCode = 0)
private ResultCode WriteBsdResult(ServiceCtx context, int result, LinuxError errorCode = 0)
{
if (errorCode != LinuxError.SUCCESS)
{
@ -129,7 +129,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
context.ResponseData.Write(result);
context.ResponseData.Write((int)errorCode);
return 0;
return ResultCode.Success;
}
private BsdSocket RetrieveSocket(int socketFd)
@ -158,7 +158,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
return AddressFamily.Unknown;
}
private long SocketInternal(ServiceCtx context, bool exempt)
private ResultCode SocketInternal(ServiceCtx context, bool exempt)
{
AddressFamily domain = (AddressFamily)context.RequestData.ReadInt32();
SocketType type = (SocketType)context.RequestData.ReadInt32();
@ -222,7 +222,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(0)]
// Initialize(nn::socket::BsdBufferConfig config, u64 pid, u64 transferMemorySize, KObject<copy, transfer_memory>, pid) -> u32 bsd_errno
public long RegisterClient(ServiceCtx context)
public ResultCode RegisterClient(ServiceCtx context)
{
/*
typedef struct {
@ -242,37 +242,37 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
Logger.PrintStub(LogClass.ServiceBsd);
return 0;
return ResultCode.Success;
}
[Command(1)]
// StartMonitoring(u64, pid)
public long StartMonitoring(ServiceCtx context)
public ResultCode StartMonitoring(ServiceCtx context)
{
ulong unknown0 = context.RequestData.ReadUInt64();
Logger.PrintStub(LogClass.ServiceBsd, new { unknown0 });
return 0;
return ResultCode.Success;
}
[Command(2)]
// Socket(u32 domain, u32 type, u32 protocol) -> (i32 ret, u32 bsd_errno)
public long Socket(ServiceCtx context)
public ResultCode Socket(ServiceCtx context)
{
return SocketInternal(context, false);
}
[Command(3)]
// SocketExempt(u32 domain, u32 type, u32 protocol) -> (i32 ret, u32 bsd_errno)
public long SocketExempt(ServiceCtx context)
public ResultCode SocketExempt(ServiceCtx context)
{
return SocketInternal(context, true);
}
[Command(4)]
// Open(u32 flags, array<unknown, 0x21> path) -> (i32 ret, u32 bsd_errno)
public long Open(ServiceCtx context)
public ResultCode Open(ServiceCtx context)
{
(long bufferPosition, long bufferSize) = context.Request.GetBufferType0x21();
@ -285,23 +285,23 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
Logger.PrintStub(LogClass.ServiceBsd, new { path, flags });
return 0;
return ResultCode.Success;
}
[Command(5)]
// Select(u32 nfds, nn::socket::timeout timeout, buffer<nn::socket::fd_set, 0x21, 0> readfds_in, buffer<nn::socket::fd_set, 0x21, 0> writefds_in, buffer<nn::socket::fd_set, 0x21, 0> errorfds_in) -> (i32 ret, u32 bsd_errno, buffer<nn::socket::fd_set, 0x22, 0> readfds_out, buffer<nn::socket::fd_set, 0x22, 0> writefds_out, buffer<nn::socket::fd_set, 0x22, 0> errorfds_out)
public long Select(ServiceCtx context)
public ResultCode Select(ServiceCtx context)
{
WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP);
Logger.PrintStub(LogClass.ServiceBsd);
return 0;
return ResultCode.Success;
}
[Command(6)]
// Poll(u32 nfds, u32 timeout, buffer<unknown, 0x21, 0> fds) -> (i32 ret, u32 bsd_errno, buffer<unknown, 0x22, 0>)
public long Poll(ServiceCtx context)
public ResultCode Poll(ServiceCtx context)
{
int fdsCount = context.RequestData.ReadInt32();
int timeout = context.RequestData.ReadInt32();
@ -427,18 +427,18 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(7)]
// Sysctl(buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>) -> (i32 ret, u32 bsd_errno, u32, buffer<unknown, 0x22, 0>)
public long Sysctl(ServiceCtx context)
public ResultCode Sysctl(ServiceCtx context)
{
WriteBsdResult(context, -1, LinuxError.EOPNOTSUPP);
Logger.PrintStub(LogClass.ServiceBsd);
return 0;
return ResultCode.Success;
}
[Command(8)]
// Recv(u32 socket, u32 flags) -> (i32 ret, u32 bsd_errno, array<i8, 0x22> message)
public long Recv(ServiceCtx context)
public ResultCode Recv(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
SocketFlags socketFlags = (SocketFlags)context.RequestData.ReadInt32();
@ -478,7 +478,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(9)]
// RecvFrom(u32 sock, u32 flags) -> (i32 ret, u32 bsd_errno, u32 addrlen, buffer<i8, 0x22, 0> message, buffer<nn::socket::sockaddr_in, 0x22, 0x10>)
public long RecvFrom(ServiceCtx context)
public ResultCode RecvFrom(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
SocketFlags socketFlags = (SocketFlags)context.RequestData.ReadInt32();
@ -522,7 +522,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(10)]
// Send(u32 socket, u32 flags, buffer<i8, 0x21, 0>) -> (i32 ret, u32 bsd_errno)
public long Send(ServiceCtx context)
public ResultCode Send(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
SocketFlags socketFlags = (SocketFlags)context.RequestData.ReadInt32();
@ -562,7 +562,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(11)]
// SendTo(u32 socket, u32 flags, buffer<i8, 0x21, 0>, buffer<nn::socket::sockaddr_in, 0x21, 0x10>) -> (i32 ret, u32 bsd_errno)
public long SendTo(ServiceCtx context)
public ResultCode SendTo(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
SocketFlags socketFlags = (SocketFlags)context.RequestData.ReadInt32();
@ -604,7 +604,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(12)]
// Accept(u32 socket) -> (i32 ret, u32 bsd_errno, u32 addrlen, buffer<nn::socket::sockaddr_in, 0x22, 0x10> addr)
public long Accept(ServiceCtx context)
public ResultCode Accept(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
@ -650,7 +650,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
context.ResponseData.Write(0x10);
return 0;
return ResultCode.Success;
}
}
@ -659,7 +659,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(13)]
// Bind(u32 socket, buffer<nn::socket::sockaddr_in, 0x21, 0x10> addr) -> (i32 ret, u32 bsd_errno)
public long Bind(ServiceCtx context)
public ResultCode Bind(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
@ -689,7 +689,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(14)]
// Connect(u32 socket, buffer<nn::socket::sockaddr_in, 0x21, 0x10>) -> (i32 ret, u32 bsd_errno)
public long Connect(ServiceCtx context)
public ResultCode Connect(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
@ -718,7 +718,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(15)]
// GetPeerName(u32 socket) -> (i32 ret, u32 bsd_errno, u32 addrlen, buffer<nn::socket::sockaddr_in, 0x22, 0x10> addr)
public long GetPeerName(ServiceCtx context)
public ResultCode GetPeerName(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
@ -741,7 +741,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(16)]
// GetSockName(u32 socket) -> (i32 ret, u32 bsd_errno, u32 addrlen, buffer<nn::socket::sockaddr_in, 0x22, 0x10> addr)
public long GetSockName(ServiceCtx context)
public ResultCode GetSockName(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
@ -764,7 +764,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(17)]
// GetSockOpt(u32 socket, u32 level, u32 option_name) -> (i32 ret, u32 bsd_errno, u32, buffer<unknown, 0x22, 0>)
public long GetSockOpt(ServiceCtx context)
public ResultCode GetSockOpt(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
int level = context.RequestData.ReadInt32();
@ -794,7 +794,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(18)]
// Listen(u32 socket, u32 backlog) -> (i32 ret, u32 bsd_errno)
public long Listen(ServiceCtx context)
public ResultCode Listen(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
int backlog = context.RequestData.ReadInt32();
@ -821,7 +821,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(19)]
// Ioctl(u32 fd, u32 request, u32 bufcount, buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>, buffer<unknown, 0x21, 0>) -> (i32 ret, u32 bsd_errno, buffer<unknown, 0x22, 0>, buffer<unknown, 0x22, 0>, buffer<unknown, 0x22, 0>, buffer<unknown, 0x22, 0>)
public long Ioctl(ServiceCtx context)
public ResultCode Ioctl(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
BsdIoctl cmd = (BsdIoctl)context.RequestData.ReadInt32();
@ -856,7 +856,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(20)]
// Fcntl(u32 socket, u32 cmd, u32 arg) -> (i32 ret, u32 bsd_errno)
public long Fcntl(ServiceCtx context)
public ResultCode Fcntl(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
int cmd = context.RequestData.ReadInt32();
@ -978,7 +978,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(21)]
// SetSockOpt(u32 socket, u32 level, u32 option_name, buffer<unknown, 0x21, 0> option_value) -> (i32 ret, u32 bsd_errno)
public long SetSockOpt(ServiceCtx context)
public ResultCode SetSockOpt(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
int level = context.RequestData.ReadInt32();
@ -1008,7 +1008,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(22)]
// Shutdown(u32 socket, u32 how) -> (i32 ret, u32 bsd_errno)
public long Shutdown(ServiceCtx context)
public ResultCode Shutdown(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
int how = context.RequestData.ReadInt32();
@ -1040,7 +1040,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(23)]
// ShutdownAllSockets(u32 how) -> (i32 ret, u32 bsd_errno)
public long ShutdownAllSockets(ServiceCtx context)
public ResultCode ShutdownAllSockets(ServiceCtx context)
{
int how = context.RequestData.ReadInt32();
@ -1072,7 +1072,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(24)]
// Write(u32 socket, buffer<i8, 0x21, 0> message) -> (i32 ret, u32 bsd_errno)
public long Write(ServiceCtx context)
public ResultCode Write(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
@ -1102,7 +1102,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(25)]
// Read(u32 socket) -> (i32 ret, u32 bsd_errno, buffer<i8, 0x22, 0> message)
public long Read(ServiceCtx context)
public ResultCode Read(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
@ -1132,7 +1132,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(26)]
// Close(u32 socket) -> (i32 ret, u32 bsd_errno)
public long Close(ServiceCtx context)
public ResultCode Close(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
@ -1153,7 +1153,7 @@ namespace Ryujinx.HLE.HOS.Services.Bsd
[Command(27)]
// DuplicateSocket(u32 socket, u64 reserved) -> (i32 ret, u32 bsd_errno)
public long DuplicateSocket(ServiceCtx context)
public ResultCode DuplicateSocket(ServiceCtx context)
{
int socketFd = context.RequestData.ReadInt32();
ulong reserved = context.RequestData.ReadUInt64();

View File

@ -25,4 +25,4 @@
OutputEvents = outputEvents;
}
}
}
}

View File

@ -1,8 +0,0 @@
namespace Ryujinx.HLE.HOS.Services.Friend
{
static class FriendError
{
public const int InvalidArgument = 2;
public const int NotificationQueueEmpty = 15;
}
}

View File

@ -16,4 +16,4 @@ namespace Ryujinx.HLE.HOS.Services.Friend
Manager = UserMask | OverlayMask | ManagerMask,
System = UserMask | SystemMask
}
}
}

View File

@ -5,8 +5,6 @@ using Ryujinx.HLE.Utilities;
using System.IO;
using System.Runtime.InteropServices;
using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.HOS.Services.Friend
{
class IFriendService : IpcService
@ -21,7 +19,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend
[Command(10100)]
// nn::friends::GetFriendListIds(int offset, nn::account::Uid userUUID, nn::friends::detail::ipc::SizedFriendFilter friendFilter, ulong pidPlaceHolder, pid)
// -> int outCount, array<nn::account::NetworkServiceAccountId, 0xa>
public long GetFriendListIds(ServiceCtx context)
public ResultCode GetFriendListIds(ServiceCtx context)
{
int offset = context.RequestData.ReadInt32();
@ -36,7 +34,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend
if (uuid.IsNull)
{
return MakeError(ErrorModule.Friends, FriendError.InvalidArgument);
return ResultCode.InvalidArgument;
}
// There are no friends online, so we return 0 because the nn::account::NetworkServiceAccountId array is empty.
@ -54,13 +52,13 @@ namespace Ryujinx.HLE.HOS.Services.Friend
filter.PresenceGroupId,
});
return 0;
return ResultCode.Success;
}
[Command(10101)]
// nn::friends::GetFriendList(int offset, nn::account::Uid userUUID, nn::friends::detail::ipc::SizedFriendFilter friendFilter, ulong pidPlaceHolder, pid)
// -> int outCount, array<nn::friends::detail::FriendImpl, 0x6>
public long GetFriendList(ServiceCtx context)
public ResultCode GetFriendList(ServiceCtx context)
{
int offset = context.RequestData.ReadInt32();
@ -75,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend
if (uuid.IsNull)
{
return MakeError(ErrorModule.Friends, FriendError.InvalidArgument);
return ResultCode.InvalidArgument;
}
// There are no friends online, so we return 0 because the nn::account::NetworkServiceAccountId array is empty.
@ -92,18 +90,18 @@ namespace Ryujinx.HLE.HOS.Services.Friend
filter.PresenceGroupId,
});
return 0;
return ResultCode.Success;
}
[Command(10600)]
// nn::friends::DeclareOpenOnlinePlaySession(nn::account::Uid)
public long DeclareOpenOnlinePlaySession(ServiceCtx context)
public ResultCode DeclareOpenOnlinePlaySession(ServiceCtx context)
{
UInt128 uuid = context.RequestData.ReadStruct<UInt128>();
if (uuid.IsNull)
{
return MakeError(ErrorModule.Friends, FriendError.InvalidArgument);
return ResultCode.InvalidArgument;
}
if (context.Device.System.State.Account.TryGetUser(uuid, out UserProfile profile))
@ -113,18 +111,18 @@ namespace Ryujinx.HLE.HOS.Services.Friend
Logger.PrintStub(LogClass.ServiceFriend, new { UserId = uuid.ToString(), profile.OnlinePlayState });
return 0;
return ResultCode.Success;
}
[Command(10601)]
// nn::friends::DeclareCloseOnlinePlaySession(nn::account::Uid)
public long DeclareCloseOnlinePlaySession(ServiceCtx context)
public ResultCode DeclareCloseOnlinePlaySession(ServiceCtx context)
{
UInt128 uuid = context.RequestData.ReadStruct<UInt128>();
if (uuid.IsNull)
{
return MakeError(ErrorModule.Friends, FriendError.InvalidArgument);
return ResultCode.InvalidArgument;
}
if (context.Device.System.State.Account.TryGetUser(uuid, out UserProfile profile))
@ -134,12 +132,12 @@ namespace Ryujinx.HLE.HOS.Services.Friend
Logger.PrintStub(LogClass.ServiceFriend, new { UserId = uuid.ToString(), profile.OnlinePlayState });
return 0;
return ResultCode.Success;
}
[Command(10610)]
// nn::friends::UpdateUserPresence(nn::account::Uid, u64, pid, buffer<nn::friends::detail::UserPresenceImpl, 0x19>)
public long UpdateUserPresence(ServiceCtx context)
public ResultCode UpdateUserPresence(ServiceCtx context)
{
UInt128 uuid = context.RequestData.ReadStruct<UInt128>();
@ -153,7 +151,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend
if (uuid.IsNull)
{
return MakeError(ErrorModule.Friends, FriendError.InvalidArgument);
return ResultCode.InvalidArgument;
}
int elementCount = bufferContent.Length / Marshal.SizeOf<UserPresence>();
@ -165,7 +163,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend
Logger.PrintStub(LogClass.ServiceFriend, new { UserId = uuid.ToString(), userPresenceInputArray });
}
return 0;
return ResultCode.Success;
}
}
}

View File

@ -101,4 +101,4 @@ namespace Ryujinx.HLE.HOS.Services.Friend
public long NetworkUserIdPlaceholder;
}
}
}

View File

@ -6,8 +6,6 @@ using Ryujinx.HLE.Utilities;
using System;
using System.Collections.Generic;
using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.HOS.Services.Friend
{
class INotificationService : IpcService, IDisposable
@ -40,7 +38,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend
[Command(0)] //2.0.0+
// nn::friends::detail::ipc::INotificationService::GetEvent() -> handle<copy>
public long GetEvent(ServiceCtx context)
public ResultCode GetEvent(ServiceCtx context)
{
if (_notificationEventHandle == 0)
{
@ -52,12 +50,12 @@ namespace Ryujinx.HLE.HOS.Services.Friend
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_notificationEventHandle);
return 0;
return ResultCode.Success;
}
[Command(1)] //2.0.0+
// nn::friends::detail::ipc::INotificationService::Clear()
public long Clear(ServiceCtx context)
public ResultCode Clear(ServiceCtx context)
{
lock (_lock)
{
@ -67,12 +65,12 @@ namespace Ryujinx.HLE.HOS.Services.Friend
_notifications.Clear();
}
return 0;
return ResultCode.Success;
}
[Command(2)] // 2.0.0+
// nn::friends::detail::ipc::INotificationService::Pop() -> nn::friends::detail::ipc::SizedNotificationInfo
public long Pop(ServiceCtx context)
public ResultCode Pop(ServiceCtx context)
{
lock (_lock)
{
@ -92,11 +90,11 @@ namespace Ryujinx.HLE.HOS.Services.Friend
context.ResponseData.WriteStruct(notificationInfo);
return 0;
return ResultCode.Success;
}
}
return MakeError(ErrorModule.Friends, FriendError.NotificationQueueEmpty);
return ResultCode.NotificationQueueEmpty;
}
public void SignalFriendListUpdate(UInt128 targetId)

View File

@ -1,8 +1,6 @@
using Ryujinx.Common;
using Ryujinx.HLE.Utilities;
using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.HOS.Services.Friend
{
[Service("friend:a", FriendServicePermissionLevel.Admin)]
@ -21,36 +19,36 @@ namespace Ryujinx.HLE.HOS.Services.Friend
[Command(0)]
// CreateFriendService() -> object<nn::friends::detail::ipc::IFriendService>
public long CreateFriendService(ServiceCtx context)
public ResultCode CreateFriendService(ServiceCtx context)
{
MakeObject(context, new IFriendService(_permissionLevel));
return 0;
return ResultCode.Success;
}
[Command(1)] // 2.0.0+
// CreateNotificationService(nn::account::Uid) -> object<nn::friends::detail::ipc::INotificationService>
public long CreateNotificationService(ServiceCtx context)
public ResultCode CreateNotificationService(ServiceCtx context)
{
UInt128 userId = context.RequestData.ReadStruct<UInt128>();
if (userId.IsNull)
{
return MakeError(ErrorModule.Friends, FriendError.InvalidArgument);
return ResultCode.InvalidArgument;
}
MakeObject(context, new INotificationService(context, userId, _permissionLevel));
return 0;
return ResultCode.Success;
}
[Command(2)] // 4.0.0+
// CreateDaemonSuspendSessionService() -> object<nn::friends::detail::ipc::IDaemonSuspendSessionService>
public long CreateDaemonSuspendSessionService(ServiceCtx context)
public ResultCode CreateDaemonSuspendSessionService(ServiceCtx context)
{
MakeObject(context, new IDaemonSuspendSessionService(_permissionLevel));
return 0;
return ResultCode.Success;
}
}
}

View File

@ -0,0 +1,13 @@
namespace Ryujinx.HLE.HOS.Services.Friend
{
enum ResultCode
{
ModuleId = 121,
ErrorCodeShift = 9,
Success = 0,
InvalidArgument = (2 << ErrorCodeShift) | ModuleId,
NotificationQueueEmpty = (15 << ErrorCodeShift) | ModuleId
}
}

View File

@ -9,4 +9,4 @@
ContentData = 6,
ApplicationPackage = 7
}
}
}

View File

@ -1,11 +0,0 @@
namespace Ryujinx.HLE.HOS.Services.FspSrv
{
static class FsErr
{
public const int PathDoesNotExist = 1;
public const int PathAlreadyExists = 2;
public const int PathAlreadyInUse = 7;
public const int PartitionNotFound = 1001;
public const int InvalidInput = 6001;
}
}

View File

@ -20,7 +20,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
[Command(0)]
// Read() -> (u64 count, buffer<nn::fssrv::sf::IDirectoryEntry, 6, 0> entries)
public long Read(ServiceCtx context)
public ResultCode Read(ServiceCtx context)
{
long bufferPosition = context.Request.ReceiveBuff[0].Position;
long bufferLen = context.Request.ReceiveBuff[0].Size;
@ -41,12 +41,12 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
context.ResponseData.Write((long)readCount);
return 0;
return ResultCode.Success;
}
private void WriteDirectoryEntry(ServiceCtx context, long position, LibHac.Fs.DirectoryEntry entry)
@ -67,7 +67,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
[Command(1)]
// GetEntryCount() -> u64
public long GetEntryCount(ServiceCtx context)
public ResultCode GetEntryCount(ServiceCtx context)
{
try
{
@ -75,10 +75,10 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
}
}

View File

@ -15,7 +15,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
[Command(0)]
// Read(u32 readOption, u64 offset, u64 size) -> (u64 out_size, buffer<u8, 0x46, 0> out_buf)
public long Read(ServiceCtx context)
public ResultCode Read(ServiceCtx context)
{
long position = context.Request.ReceiveBuff[0].Position;
@ -34,19 +34,19 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
context.Memory.WriteBytes(position, data);
context.ResponseData.Write((long)readSize);
return 0;
return ResultCode.Success;
}
[Command(1)]
// Write(u32 writeOption, u64 offset, u64 size, buffer<u8, 0x45, 0>)
public long Write(ServiceCtx context)
public ResultCode Write(ServiceCtx context)
{
long position = context.Request.SendBuff[0].Position;
@ -64,15 +64,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(2)]
// Flush()
public long Flush(ServiceCtx context)
public ResultCode Flush(ServiceCtx context)
{
try
{
@ -80,15 +80,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(3)]
// SetSize(u64 size)
public long SetSize(ServiceCtx context)
public ResultCode SetSize(ServiceCtx context)
{
try
{
@ -98,15 +98,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(4)]
// GetSize() -> u64 fileSize
public long GetSize(ServiceCtx context)
public ResultCode GetSize(ServiceCtx context)
{
try
{
@ -114,10 +114,10 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
public void Dispose()

View File

@ -1,7 +1,6 @@
using LibHac;
using LibHac.Fs;
using static Ryujinx.HLE.HOS.ErrorCode;
using static Ryujinx.HLE.Utilities.StringUtils;
namespace Ryujinx.HLE.HOS.Services.FspSrv
@ -17,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
[Command(0)]
// CreateFile(u32 createOption, u64 size, buffer<bytes<0x301>, 0x19, 0x301> path)
public long CreateFile(ServiceCtx context)
public ResultCode CreateFile(ServiceCtx context)
{
string name = ReadUtf8String(context);
@ -32,15 +31,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(1)]
// DeleteFile(buffer<bytes<0x301>, 0x19, 0x301> path)
public long DeleteFile(ServiceCtx context)
public ResultCode DeleteFile(ServiceCtx context)
{
string name = ReadUtf8String(context);
@ -50,15 +49,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(2)]
// CreateDirectory(buffer<bytes<0x301>, 0x19, 0x301> path)
public long CreateDirectory(ServiceCtx context)
public ResultCode CreateDirectory(ServiceCtx context)
{
string name = ReadUtf8String(context);
@ -68,15 +67,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(3)]
// DeleteDirectory(buffer<bytes<0x301>, 0x19, 0x301> path)
public long DeleteDirectory(ServiceCtx context)
public ResultCode DeleteDirectory(ServiceCtx context)
{
string name = ReadUtf8String(context);
@ -86,15 +85,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(4)]
// DeleteDirectoryRecursively(buffer<bytes<0x301>, 0x19, 0x301> path)
public long DeleteDirectoryRecursively(ServiceCtx context)
public ResultCode DeleteDirectoryRecursively(ServiceCtx context)
{
string name = ReadUtf8String(context);
@ -104,15 +103,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(5)]
// RenameFile(buffer<bytes<0x301>, 0x19, 0x301> oldPath, buffer<bytes<0x301>, 0x19, 0x301> newPath)
public long RenameFile(ServiceCtx context)
public ResultCode RenameFile(ServiceCtx context)
{
string oldName = ReadUtf8String(context, 0);
string newName = ReadUtf8String(context, 1);
@ -123,15 +122,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(6)]
// RenameDirectory(buffer<bytes<0x301>, 0x19, 0x301> oldPath, buffer<bytes<0x301>, 0x19, 0x301> newPath)
public long RenameDirectory(ServiceCtx context)
public ResultCode RenameDirectory(ServiceCtx context)
{
string oldName = ReadUtf8String(context, 0);
string newName = ReadUtf8String(context, 1);
@ -142,15 +141,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(7)]
// GetEntryType(buffer<bytes<0x301>, 0x19, 0x301> path) -> nn::fssrv::sf::DirectoryEntryType
public long GetEntryType(ServiceCtx context)
public ResultCode GetEntryType(ServiceCtx context)
{
string name = ReadUtf8String(context);
@ -164,20 +163,20 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
else
{
return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist);
return ResultCode.PathDoesNotExist;
}
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(8)]
// OpenFile(u32 mode, buffer<bytes<0x301>, 0x19, 0x301> path) -> object<nn::fssrv::sf::IFile> file
public long OpenFile(ServiceCtx context)
public ResultCode OpenFile(ServiceCtx context)
{
OpenMode mode = (OpenMode)context.RequestData.ReadInt32();
@ -193,15 +192,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(9)]
// OpenDirectory(u32 filter_flags, buffer<bytes<0x301>, 0x19, 0x301> path) -> object<nn::fssrv::sf::IDirectory> directory
public long OpenDirectory(ServiceCtx context)
public ResultCode OpenDirectory(ServiceCtx context)
{
OpenDirectoryMode mode = (OpenDirectoryMode)context.RequestData.ReadInt32();
@ -217,15 +216,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(10)]
// Commit()
public long Commit(ServiceCtx context)
public ResultCode Commit(ServiceCtx context)
{
try
{
@ -233,15 +232,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(11)]
// GetFreeSpaceSize(buffer<bytes<0x301>, 0x19, 0x301> path) -> u64 totalFreeSpace
public long GetFreeSpaceSize(ServiceCtx context)
public ResultCode GetFreeSpaceSize(ServiceCtx context)
{
string name = ReadUtf8String(context);
@ -251,15 +250,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(12)]
// GetTotalSpaceSize(buffer<bytes<0x301>, 0x19, 0x301> path) -> u64 totalSize
public long GetTotalSpaceSize(ServiceCtx context)
public ResultCode GetTotalSpaceSize(ServiceCtx context)
{
string name = ReadUtf8String(context);
@ -269,15 +268,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(13)]
// CleanDirectoryRecursively(buffer<bytes<0x301>, 0x19, 0x301> path)
public long CleanDirectoryRecursively(ServiceCtx context)
public ResultCode CleanDirectoryRecursively(ServiceCtx context)
{
string name = ReadUtf8String(context);
@ -287,15 +286,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
[Command(14)]
// GetFileTimeStampRaw(buffer<bytes<0x301>, 0x19, 0x301> path) -> bytes<0x20> timestamp
public long GetFileTimeStampRaw(ServiceCtx context)
public ResultCode GetFileTimeStampRaw(ServiceCtx context)
{
string name = ReadUtf8String(context);
@ -316,10 +315,10 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
}
}

View File

@ -8,7 +8,6 @@ using Ryujinx.HLE.Utilities;
using System.IO;
using static Ryujinx.HLE.FileSystem.VirtualFileSystem;
using static Ryujinx.HLE.HOS.ErrorCode;
using static Ryujinx.HLE.Utilities.StringUtils;
namespace Ryujinx.HLE.HOS.Services.FspSrv
@ -20,15 +19,15 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
[Command(1)]
// Initialize(u64, pid)
public long Initialize(ServiceCtx context)
public ResultCode Initialize(ServiceCtx context)
{
return 0;
return ResultCode.Success;
}
[Command(8)]
// OpenFileSystemWithId(nn::fssrv::sf::FileSystemType filesystem_type, nn::ApplicationId tid, buffer<bytes<0x301>, 0x19, 0x301> path)
// -> object<nn::fssrv::sf::IFileSystem> contentFs
public long OpenFileSystemWithId(ServiceCtx context)
public ResultCode OpenFileSystemWithId(ServiceCtx context)
{
FileSystemType fileSystemType = (FileSystemType)context.RequestData.ReadInt32();
long titleId = context.RequestData.ReadInt64();
@ -42,7 +41,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
return OpenFileSystemFromInternalFile(context, fullPath);
}
return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist);
return ResultCode.PathDoesNotExist;
}
FileStream fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read);
@ -57,12 +56,12 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
return OpenNsp(context, fullPath);
}
return MakeError(ErrorModule.Fs, FsErr.InvalidInput);
return ResultCode.InvalidInput;
}
[Command(11)]
// OpenBisFileSystem(nn::fssrv::sf::Partition partitionID, buffer<bytes<0x301>, 0x19, 0x301>) -> object<nn::fssrv::sf::IFileSystem> Bis
public long OpenBisFileSystem(ServiceCtx context)
public ResultCode OpenBisFileSystem(ServiceCtx context)
{
int bisPartitionId = context.RequestData.ReadInt32();
string partitionString = ReadUtf8String(context);
@ -81,7 +80,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
bisPartitionPath = UserNandPath;
break;
default:
return MakeError(ErrorModule.Fs, FsErr.InvalidInput);
return ResultCode.InvalidInput;
}
string fullPath = context.Device.FileSystem.GetFullPartitionPath(bisPartitionPath);
@ -90,12 +89,12 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
MakeObject(context, new IFileSystem(fileSystem));
return 0;
return ResultCode.Success;
}
[Command(18)]
// OpenSdCardFileSystem() -> object<nn::fssrv::sf::IFileSystem>
public long OpenSdCardFileSystem(ServiceCtx context)
public ResultCode OpenSdCardFileSystem(ServiceCtx context)
{
string sdCardPath = context.Device.FileSystem.GetSdCardPath();
@ -103,26 +102,26 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
MakeObject(context, new IFileSystem(fileSystem));
return 0;
return ResultCode.Success;
}
[Command(51)]
// OpenSaveDataFileSystem(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> saveDataFs
public long OpenSaveDataFileSystem(ServiceCtx context)
public ResultCode OpenSaveDataFileSystem(ServiceCtx context)
{
return LoadSaveDataFileSystem(context);
}
[Command(52)]
// OpenSaveDataFileSystemBySystemSaveDataId(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> systemSaveDataFs
public long OpenSaveDataFileSystemBySystemSaveDataId(ServiceCtx context)
public ResultCode OpenSaveDataFileSystemBySystemSaveDataId(ServiceCtx context)
{
return LoadSaveDataFileSystem(context);
}
[Command(200)]
// OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage
public long OpenDataStorageByCurrentProcess(ServiceCtx context)
public ResultCode OpenDataStorageByCurrentProcess(ServiceCtx context)
{
MakeObject(context, new IStorage(context.Device.FileSystem.RomFs.AsStorage()));
@ -131,7 +130,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
[Command(202)]
// OpenDataStorageByDataId(u8 storageId, nn::ApplicationId tid) -> object<nn::fssrv::sf::IStorage> dataStorage
public long OpenDataStorageByDataId(ServiceCtx context)
public ResultCode OpenDataStorageByDataId(ServiceCtx context)
{
StorageId storageId = (StorageId)context.RequestData.ReadByte();
byte[] padding = context.RequestData.ReadBytes(7);
@ -171,10 +170,10 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
else
{
@ -192,37 +191,37 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
[Command(203)]
// OpenPatchDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage>
public long OpenPatchDataStorageByCurrentProcess(ServiceCtx context)
public ResultCode OpenPatchDataStorageByCurrentProcess(ServiceCtx context)
{
MakeObject(context, new IStorage(context.Device.FileSystem.RomFs.AsStorage()));
return 0;
return ResultCode.Success;
}
[Command(1005)]
// GetGlobalAccessLogMode() -> u32 logMode
public long GetGlobalAccessLogMode(ServiceCtx context)
public ResultCode GetGlobalAccessLogMode(ServiceCtx context)
{
int mode = context.Device.System.GlobalAccessLogMode;
context.ResponseData.Write(mode);
return 0;
return ResultCode.Success;
}
[Command(1006)]
// OutputAccessLogToSdCard(buffer<bytes, 5> log_text)
public long OutputAccessLogToSdCard(ServiceCtx context)
public ResultCode OutputAccessLogToSdCard(ServiceCtx context)
{
string message = ReadUtf8StringSend(context);
// FS ends each line with a newline. Remove it because Ryujinx logging adds its own newline
Logger.PrintAccessLog(LogClass.ServiceFs, message.TrimEnd('\n'));
return 0;
return ResultCode.Success;
}
public long LoadSaveDataFileSystem(ServiceCtx context)
public ResultCode LoadSaveDataFileSystem(ServiceCtx context)
{
SaveSpaceId saveSpaceId = (SaveSpaceId)context.RequestData.ReadInt64();
@ -244,13 +243,13 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
private long OpenNsp(ServiceCtx context, string pfsPath)
private ResultCode OpenNsp(ServiceCtx context, string pfsPath)
{
try
{
@ -265,13 +264,13 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
private long OpenNcaFs(ServiceCtx context, string ncaPath, LibHac.Fs.IStorage ncaStorage)
private ResultCode OpenNcaFs(ServiceCtx context, string ncaPath, LibHac.Fs.IStorage ncaStorage)
{
try
{
@ -279,7 +278,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
if (!nca.SectionExists(NcaSectionType.Data))
{
return MakeError(ErrorModule.Fs, FsErr.PartitionNotFound);
return ResultCode.PartitionNotFound;
}
LibHac.Fs.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
@ -288,13 +287,13 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
private long OpenFileSystemFromInternalFile(ServiceCtx context, string fullPath)
private ResultCode OpenFileSystemFromInternalFile(ServiceCtx context, string fullPath)
{
DirectoryInfo archivePath = new DirectoryInfo(fullPath).Parent;
@ -325,11 +324,11 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
}
return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist);
return ResultCode.PathDoesNotExist;
}
private void ImportTitleKeysFromNsp(LibHac.Fs.IFileSystem nsp, Keyset keySet)

View File

@ -14,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
[Command(0)]
// Read(u64 offset, u64 length) -> buffer<u8, 0x46, 0> buffer
public long Read(ServiceCtx context)
public ResultCode Read(ServiceCtx context)
{
long offset = context.RequestData.ReadInt64();
long size = context.RequestData.ReadInt64();
@ -37,18 +37,18 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
context.Memory.WriteBytes(buffDesc.Position, data);
}
return 0;
return ResultCode.Success;
}
[Command(4)]
// GetSize() -> u64 size
public long GetSize(ServiceCtx context)
public ResultCode GetSize(ServiceCtx context)
{
try
{
@ -56,10 +56,10 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
}
catch (HorizonResultException ex)
{
return ex.ResultValue.Value;
return (ResultCode)ex.ResultValue.Value;
}
return 0;
return ResultCode.Success;
}
}
}

View File

@ -0,0 +1,16 @@
namespace Ryujinx.HLE.HOS.Services.FspSrv
{
enum ResultCode
{
ModuleId = 2,
ErrorCodeShift = 9,
Success = 0,
PathDoesNotExist = (1 << ErrorCodeShift) | ModuleId,
PathAlreadyExists = (2 << ErrorCodeShift) | ModuleId,
PathAlreadyInUse = (7 << ErrorCodeShift) | ModuleId,
PartitionNotFound = (1001 << ErrorCodeShift) | ModuleId,
InvalidInput = (6001 << ErrorCodeShift) | ModuleId
}
}

View File

@ -38,4 +38,4 @@ namespace Ryujinx.HLE.HOS.Services.Hid
Right = 1 << 4,
Invalid = 1 << 5
}
}
}

View File

@ -18,4 +18,4 @@
Standard,
Tight
}
}
}

View File

@ -26,4 +26,4 @@
public float AmplitudeHigh;
public float FrequencyHigh;
}
}
}

View File

@ -6,11 +6,11 @@ namespace Ryujinx.HLE.HOS.Services.Hid
[Command(0)]
// ActivateVibrationDevice(nn::hid::VibrationDeviceHandle)
public long ActivateVibrationDevice(ServiceCtx context)
public ResultCode ActivateVibrationDevice(ServiceCtx context)
{
int vibrationDeviceHandle = context.RequestData.ReadInt32();
return 0;
return ResultCode.Success;
}
}
}

View File

@ -16,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
[Command(0)]
// GetSharedMemoryHandle() -> handle<copy>
public long GetSharedMemoryHandle(ServiceCtx context)
public ResultCode GetSharedMemoryHandle(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_hidSharedMem, out int handle) != KernelResult.Success)
{
@ -25,7 +25,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
return 0;
return ResultCode.Success;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -15,29 +15,29 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
[Command(302)]
// ActivateIrsensor(nn::applet::AppletResourceUserId, pid)
public long ActivateIrsensor(ServiceCtx context)
public ResultCode ActivateIrsensor(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId });
return 0;
return ResultCode.Success;
}
[Command(303)]
// DeactivateIrsensor(nn::applet::AppletResourceUserId, pid)
public long DeactivateIrsensor(ServiceCtx context)
public ResultCode DeactivateIrsensor(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId });
return 0;
return ResultCode.Success;
}
[Command(304)]
// GetIrsensorSharedMemoryHandle(nn::applet::AppletResourceUserId, pid) -> handle<copy>
public long GetIrsensorSharedMemoryHandle(ServiceCtx context)
public ResultCode GetIrsensorSharedMemoryHandle(ServiceCtx context)
{
if (_irsensorSharedMemoryHandle == 0)
{
@ -49,12 +49,12 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_irsensorSharedMemoryHandle);
return 0;
return ResultCode.Success;
}
[Command(311)]
// GetNpadIrCameraHandle(u32) -> nn::irsensor::IrCameraHandle
public long GetNpadIrCameraHandle(ServiceCtx context)
public ResultCode GetNpadIrCameraHandle(ServiceCtx context)
{
NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32();
@ -62,7 +62,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
npadIdType != NpadIdType.Unknown &&
npadIdType != NpadIdType.Handheld)
{
return ErrorCode.MakeError(ErrorModule.Irsensor, IrsError.NpadIdOutOfRange);
return ResultCode.NpadIdOutOfRange;
}
HidControllerId irCameraHandle = HidUtils.GetIndexFromNpadIdType(npadIdType);
@ -70,21 +70,21 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
context.ResponseData.Write((int)irCameraHandle);
// NOTE: If the irCameraHandle pointer is null this error is returned, Doesn't occur in our case.
// return ErrorCode.MakeError(ErrorModule.Irsensor, IrsError.HandlePointerIsNull);
// return ResultCode.HandlePointerIsNull;
return 0;
return ResultCode.Success;
}
[Command(319)] // 4.0.0+
// ActivateIrsensorWithFunctionLevel(nn::applet::AppletResourceUserId, nn::irsensor::PackedFunctionLevel, pid)
public long ActivateIrsensorWithFunctionLevel(ServiceCtx context)
public ResultCode ActivateIrsensorWithFunctionLevel(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
long packedFunctionLevel = context.RequestData.ReadInt64();
Logger.PrintStub(LogClass.ServiceIrs, new { appletResourceUserId, packedFunctionLevel });
return 0;
return ResultCode.Success;
}
}
}

View File

@ -1,8 +0,0 @@
namespace Ryujinx.HLE.HOS.Services.Hid.Irs
{
static class IrsError
{
public const int HandlePointerIsNull = 212;
public const int NpadIdOutOfRange = 709;
}
}

View File

@ -0,0 +1,13 @@
namespace Ryujinx.HLE.HOS.Services.Hid.Irs
{
public enum ResultCode
{
ModuleId = 205,
ErrorCodeShift = 9,
Success = 0,
HandlePointerIsNull = (212 << ErrorCodeShift) | ModuleId,
NpadIdOutOfRange = (709 << ErrorCodeShift) | ModuleId
}
}

View File

@ -103,7 +103,7 @@ namespace Ryujinx.HLE.HOS.Services
if (ServiceConfiguration.IgnoreMissingServices || serviceExists)
{
long result = 0;
ResultCode result = ResultCode.Success;
context.ResponseData.BaseStream.Seek(_isDomain ? 0x20 : 0x10, SeekOrigin.Begin);
@ -118,7 +118,7 @@ namespace Ryujinx.HLE.HOS.Services
Profile.Begin(profile);
result = (long)processRequest.Invoke(service, new object[] { context });
result = (ResultCode)processRequest.Invoke(service, new object[] { context });
Profile.End(profile);
}
@ -148,7 +148,7 @@ namespace Ryujinx.HLE.HOS.Services
context.ResponseData.BaseStream.Seek(_isDomain ? 0x10 : 0, SeekOrigin.Begin);
context.ResponseData.Write(IpcMagic.Sfco);
context.ResponseData.Write(result);
context.ResponseData.Write((long)result);
}
else
{

View File

@ -12,8 +12,6 @@ using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.HOS.Services.Ldr
{
[StructLayout(LayoutKind.Explicit, Size = 0x350)]
@ -115,17 +113,17 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
_nroInfos = new List<NroInfo>(MaxNro);
}
private long ParseNrr(out NrrInfo nrrInfo, ServiceCtx context, long nrrAddress, long nrrSize)
private ResultCode ParseNrr(out NrrInfo nrrInfo, ServiceCtx context, long nrrAddress, long nrrSize)
{
nrrInfo = null;
if (nrrSize == 0 || nrrAddress + nrrSize <= nrrAddress || (nrrSize & 0xFFF) != 0)
{
return MakeError(ErrorModule.Loader, LoaderErr.BadSize);
return ResultCode.BadSize;
}
else if ((nrrAddress & 0xFFF) != 0)
{
return MakeError(ErrorModule.Loader, LoaderErr.UnalignedAddress);
return ResultCode.UnalignedAddress;
}
StructReader reader = new StructReader(context.Memory, nrrAddress);
@ -133,11 +131,11 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
if (header.Magic != NrrMagic)
{
return MakeError(ErrorModule.Loader, LoaderErr.InvalidNrr);
return ResultCode.InvalidNrr;
}
else if (header.NrrSize != nrrSize)
{
return MakeError(ErrorModule.Loader, LoaderErr.BadSize);
return ResultCode.BadSize;
}
List<byte[]> hashes = new List<byte[]>();
@ -149,7 +147,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
nrrInfo = new NrrInfo(nrrAddress, header, hashes);
return 0;
return ResultCode.Success;
}
public bool IsNroHashPresent(byte[] nroHash)
@ -181,25 +179,25 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
return false;
}
public long ParseNro(out NroInfo res, ServiceCtx context, ulong nroAddress, ulong nroSize, ulong bssAddress, ulong bssSize)
public ResultCode ParseNro(out NroInfo res, ServiceCtx context, ulong nroAddress, ulong nroSize, ulong bssAddress, ulong bssSize)
{
res = null;
if (_nroInfos.Count >= MaxNro)
{
return MakeError(ErrorModule.Loader, LoaderErr.MaxNro);
return ResultCode.MaxNro;
}
else if (nroSize == 0 || nroAddress + nroSize <= nroAddress || (nroSize & 0xFFF) != 0)
{
return MakeError(ErrorModule.Loader, LoaderErr.BadSize);
return ResultCode.BadSize;
}
else if (bssSize != 0 && bssAddress + bssSize <= bssAddress)
{
return MakeError(ErrorModule.Loader, LoaderErr.BadSize);
return ResultCode.BadSize;
}
else if ((nroAddress & 0xFFF) != 0)
{
return MakeError(ErrorModule.Loader, LoaderErr.UnalignedAddress);
return ResultCode.UnalignedAddress;
}
uint magic = context.Memory.ReadUInt32((long)nroAddress + 0x10);
@ -207,7 +205,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
if (magic != NroMagic || nroSize != nroFileSize)
{
return MakeError(ErrorModule.Loader, LoaderErr.InvalidNro);
return ResultCode.InvalidNro;
}
byte[] nroData = context.Memory.ReadBytes((long)nroAddress, (long)nroSize);
@ -222,12 +220,12 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
if (!IsNroHashPresent(nroHash))
{
return MakeError(ErrorModule.Loader, LoaderErr.NroHashNotPresent);
return ResultCode.NroHashNotPresent;
}
if (IsNroLoaded(nroHash))
{
return MakeError(ErrorModule.Loader, LoaderErr.NroAlreadyLoaded);
return ResultCode.NroAlreadyLoaded;
}
stream.Position = 0;
@ -238,7 +236,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
if ((executable.Text.Length & 0xFFF) != 0 || (executable.Ro.Length & 0xFFF) != 0 ||
(executable.Data.Length & 0xFFF) != 0 || (executable.BssSize & 0xFFF) != 0)
{
return MakeError(ErrorModule.Loader, LoaderErr.InvalidNro);
return ResultCode.InvalidNro;
}
// check if everything is contiguous.
@ -246,13 +244,13 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
executable.DataOffset != executable.RoOffset + executable.Ro.Length ||
nroFileSize != executable.DataOffset + executable.Data.Length)
{
return MakeError(ErrorModule.Loader, LoaderErr.InvalidNro);
return ResultCode.InvalidNro;
}
// finally check the bss size match.
if ((ulong)executable.BssSize != bssSize)
{
return MakeError(ErrorModule.Loader, LoaderErr.InvalidNro);
return ResultCode.InvalidNro;
}
int totalSize = executable.Text.Length + executable.Ro.Length + executable.Data.Length + executable.BssSize;
@ -266,10 +264,10 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
bssSize,
(ulong)totalSize);
return 0;
return ResultCode.Success;
}
private long MapNro(ServiceCtx context, NroInfo info, out ulong nroMappedAddress)
private ResultCode MapNro(ServiceCtx context, NroInfo info, out ulong nroMappedAddress)
{
nroMappedAddress = 0;
@ -281,7 +279,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
{
if (targetAddress + info.TotalSize >= memMgr.AddrSpaceEnd)
{
return MakeError(ErrorModule.Loader, LoaderErr.InvalidMemoryState);
return ResultCode.InvalidMemoryState;
}
KMemoryInfo memInfo = memMgr.QueryMemory(targetAddress);
@ -302,7 +300,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
if (result != KernelResult.Success)
{
return MakeError(ErrorModule.Loader, LoaderErr.InvalidMemoryState);
return ResultCode.InvalidMemoryState;
}
ulong bssTargetAddress = targetAddress + info.NroSize;
@ -315,7 +313,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
{
memMgr.UnmapProcessCodeMemory(targetAddress, info.NroAddress, info.NroSize);
return MakeError(ErrorModule.Loader, LoaderErr.InvalidMemoryState);
return ResultCode.InvalidMemoryState;
}
}
@ -330,13 +328,13 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
memMgr.UnmapProcessCodeMemory(bssTargetAddress, info.BssAddress, info.BssSize);
}
return 0;
return ResultCode.Success;
}
info.NroMappedAddress = targetAddress;
nroMappedAddress = targetAddress;
return 0;
return ResultCode.Success;
}
private KernelResult LoadNroIntoMemory(KProcess process, IExecutable relocatableObject, ulong baseAddress)
@ -374,7 +372,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
return process.MemoryManager.SetProcessMemoryPermission(dataStart, bssEnd - dataStart, MemoryPermission.ReadAndWrite);
}
private long RemoveNrrInfo(long nrrAddress)
private ResultCode RemoveNrrInfo(long nrrAddress)
{
foreach (NrrInfo info in _nrrInfos)
{
@ -382,14 +380,14 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
{
_nrrInfos.Remove(info);
return 0;
return ResultCode.Success;
}
}
return MakeError(ErrorModule.Loader, LoaderErr.BadNrrAddress);
return ResultCode.BadNrrAddress;
}
private long RemoveNroInfo(ServiceCtx context, ulong nroMappedAddress)
private ResultCode RemoveNroInfo(ServiceCtx context, ulong nroMappedAddress)
{
foreach (NroInfo info in _nroInfos)
{
@ -428,18 +426,18 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
}
}
return (long)result;
return (ResultCode)result;
}
}
return MakeError(ErrorModule.Loader, LoaderErr.BadNroAddress);
return ResultCode.BadNroAddress;
}
[Command(0)]
// LoadNro(u64, u64, u64, u64, u64, pid) -> u64
public long LoadNro(ServiceCtx context)
public ResultCode LoadNro(ServiceCtx context)
{
long result = MakeError(ErrorModule.Loader, LoaderErr.BadInitialization);
ResultCode result = ResultCode.BadInitialization;
// Zero
context.RequestData.ReadUInt64();
@ -475,9 +473,9 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
[Command(1)]
// UnloadNro(u64, u64, pid)
public long UnloadNro(ServiceCtx context)
public ResultCode UnloadNro(ServiceCtx context)
{
long result = MakeError(ErrorModule.Loader, LoaderErr.BadInitialization);
ResultCode result = ResultCode.BadInitialization;
// Zero
context.RequestData.ReadUInt64();
@ -488,7 +486,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
{
if ((nroMappedAddress & 0xFFF) != 0)
{
return MakeError(ErrorModule.Loader, LoaderErr.UnalignedAddress);
return ResultCode.UnalignedAddress;
}
result = RemoveNroInfo(context, nroMappedAddress);
@ -499,9 +497,9 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
[Command(2)]
// LoadNrr(u64, u64, u64, pid)
public long LoadNrr(ServiceCtx context)
public ResultCode LoadNrr(ServiceCtx context)
{
long result = MakeError(ErrorModule.Loader, LoaderErr.BadInitialization);
ResultCode result = ResultCode.BadInitialization;
// Zero
context.RequestData.ReadUInt64();
@ -518,7 +516,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
{
if (_nrrInfos.Count >= MaxNrr)
{
result = MakeError(ErrorModule.Loader, LoaderErr.MaxNrr);
result = ResultCode.MaxNrr;
}
else
{
@ -532,9 +530,9 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
[Command(3)]
// UnloadNrr(u64, u64, pid)
public long UnloadNrr(ServiceCtx context)
public ResultCode UnloadNrr(ServiceCtx context)
{
long result = MakeError(ErrorModule.Loader, LoaderErr.BadInitialization);
ResultCode result = ResultCode.BadInitialization;
// Zero
context.RequestData.ReadUInt64();
@ -545,7 +543,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
{
if ((nrrHeapAddress & 0xFFF) != 0)
{
return MakeError(ErrorModule.Loader, LoaderErr.UnalignedAddress);
return ResultCode.UnalignedAddress;
}
result = RemoveNrrInfo(nrrHeapAddress);
@ -556,12 +554,12 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
[Command(4)]
// Initialize(u64, pid, KObject)
public long Initialize(ServiceCtx context)
public ResultCode Initialize(ServiceCtx context)
{
// TODO: we actually ignore the pid and process handle receive, we will need to use them when we will have multi process support.
_isInitialized = true;
return 0;
return ResultCode.Success;
}
}
}

View File

@ -1,18 +0,0 @@
namespace Ryujinx.HLE.HOS.Services.Ldr
{
static class LoaderErr
{
public const int InvalidMemoryState = 51;
public const int InvalidNro = 52;
public const int InvalidNrr = 53;
public const int MaxNro = 55;
public const int MaxNrr = 56;
public const int NroAlreadyLoaded = 57;
public const int NroHashNotPresent = 54;
public const int UnalignedAddress = 81;
public const int BadSize = 82;
public const int BadNroAddress = 84;
public const int BadNrrAddress = 85;
public const int BadInitialization = 87;
}
}

View File

@ -0,0 +1,23 @@
namespace Ryujinx.HLE.HOS.Services.Ldr
{
enum ResultCode
{
ModuleId = 9,
ErrorCodeShift = 9,
Success = 0,
InvalidMemoryState = (51 << ErrorCodeShift) | ModuleId,
InvalidNro = (52 << ErrorCodeShift) | ModuleId,
InvalidNrr = (53 << ErrorCodeShift) | ModuleId,
MaxNro = (55 << ErrorCodeShift) | ModuleId,
MaxNrr = (56 << ErrorCodeShift) | ModuleId,
NroAlreadyLoaded = (57 << ErrorCodeShift) | ModuleId,
NroHashNotPresent = (54 << ErrorCodeShift) | ModuleId,
UnalignedAddress = (81 << ErrorCodeShift) | ModuleId,
BadSize = (82 << ErrorCodeShift) | ModuleId,
BadNroAddress = (84 << ErrorCodeShift) | ModuleId,
BadNrrAddress = (85 << ErrorCodeShift) | ModuleId,
BadInitialization = (87 << ErrorCodeShift) | ModuleId
}
}

View File

@ -7,11 +7,11 @@ namespace Ryujinx.HLE.HOS.Services.Lm
[Command(0)]
// Initialize(u64, pid) -> object<nn::lm::ILogger>
public long Initialize(ServiceCtx context)
public ResultCode Initialize(ServiceCtx context)
{
MakeObject(context, new ILogger());
return 0;
return ResultCode.Success;
}
}
}

View File

@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Lm
[Command(0)]
// Log(buffer<unknown, 0x21>)
public long Log(ServiceCtx context)
public ResultCode Log(ServiceCtx context)
{
(long bufPos, long bufSize) = context.Request.GetBufferType0x21();
byte[] logBuffer = context.Memory.ReadBytes(bufPos, bufSize);
@ -80,7 +80,7 @@ namespace Ryujinx.HLE.HOS.Services.Lm
Logger.PrintGuest(LogClass.ServiceLm, text);
}
return 0;
return ResultCode.Success;
}
}
}

View File

@ -3,7 +3,6 @@ using Ryujinx.HLE.FileSystem;
using Ryujinx.HLE.FileSystem.Content;
using System.Text;
using static Ryujinx.HLE.HOS.ErrorCode;
using static Ryujinx.HLE.Utilities.StringUtils;
namespace Ryujinx.HLE.HOS.Services.Lr
@ -19,199 +18,199 @@ namespace Ryujinx.HLE.HOS.Services.Lr
[Command(0)]
// ResolveProgramPath()
public long ResolveProgramPath(ServiceCtx context)
public ResultCode ResolveProgramPath(ServiceCtx context)
{
long titleId = context.RequestData.ReadInt64();
if (ResolvePath(context, titleId, ContentType.Program))
{
return 0;
return ResultCode.Success;
}
else
{
return MakeError(ErrorModule.Lr, LrErr.ProgramLocationEntryNotFound);
return ResultCode.ProgramLocationEntryNotFound;
}
}
[Command(1)]
// RedirectProgramPath()
public long RedirectProgramPath(ServiceCtx context)
public ResultCode RedirectProgramPath(ServiceCtx context)
{
long titleId = context.RequestData.ReadInt64();
RedirectPath(context, titleId, 0, ContentType.Program);
return 0;
return ResultCode.Success;
}
[Command(2)]
// ResolveApplicationControlPath()
public long ResolveApplicationControlPath(ServiceCtx context)
public ResultCode ResolveApplicationControlPath(ServiceCtx context)
{
long titleId = context.RequestData.ReadInt64();
if (ResolvePath(context, titleId, ContentType.Control))
{
return 0;
return ResultCode.Success;
}
else
{
return MakeError(ErrorModule.Lr, LrErr.AccessDenied);
return ResultCode.AccessDenied;
}
}
[Command(3)]
// ResolveApplicationHtmlDocumentPath()
public long ResolveApplicationHtmlDocumentPath(ServiceCtx context)
public ResultCode ResolveApplicationHtmlDocumentPath(ServiceCtx context)
{
long titleId = context.RequestData.ReadInt64();
if (ResolvePath(context, titleId, ContentType.Manual))
{
return 0;
return ResultCode.Success;
}
else
{
return MakeError(ErrorModule.Lr, LrErr.AccessDenied);
return ResultCode.AccessDenied;
}
}
[Command(4)]
// ResolveDataPath()
public long ResolveDataPath(ServiceCtx context)
public ResultCode ResolveDataPath(ServiceCtx context)
{
long titleId = context.RequestData.ReadInt64();
if (ResolvePath(context, titleId, ContentType.Data) || ResolvePath(context, titleId, ContentType.PublicData))
{
return 0;
return ResultCode.Success;
}
else
{
return MakeError(ErrorModule.Lr, LrErr.AccessDenied);
return ResultCode.AccessDenied;
}
}
[Command(5)]
// RedirectApplicationControlPath()
public long RedirectApplicationControlPath(ServiceCtx context)
public ResultCode RedirectApplicationControlPath(ServiceCtx context)
{
long titleId = context.RequestData.ReadInt64();
RedirectPath(context, titleId, 1, ContentType.Control);
return 0;
return ResultCode.Success;
}
[Command(6)]
// RedirectApplicationHtmlDocumentPath()
public long RedirectApplicationHtmlDocumentPath(ServiceCtx context)
public ResultCode RedirectApplicationHtmlDocumentPath(ServiceCtx context)
{
long titleId = context.RequestData.ReadInt64();
RedirectPath(context, titleId, 1, ContentType.Manual);
return 0;
return ResultCode.Success;
}
[Command(7)]
// ResolveApplicationLegalInformationPath()
public long ResolveApplicationLegalInformationPath(ServiceCtx context)
public ResultCode ResolveApplicationLegalInformationPath(ServiceCtx context)
{
long titleId = context.RequestData.ReadInt64();
if (ResolvePath(context, titleId, ContentType.Manual))
{
return 0;
return ResultCode.Success;
}
else
{
return MakeError(ErrorModule.Lr, LrErr.AccessDenied);
return ResultCode.AccessDenied;
}
}
[Command(8)]
// RedirectApplicationLegalInformationPath()
public long RedirectApplicationLegalInformationPath(ServiceCtx context)
public ResultCode RedirectApplicationLegalInformationPath(ServiceCtx context)
{
long titleId = context.RequestData.ReadInt64();
RedirectPath(context, titleId, 1, ContentType.Manual);
return 0;
return ResultCode.Success;
}
[Command(9)]
// Refresh()
public long Refresh(ServiceCtx context)
public ResultCode Refresh(ServiceCtx context)
{
context.Device.System.ContentManager.RefreshEntries(_storageId, 1);
return 0;
return ResultCode.Success;
}
[Command(10)]
// SetProgramNcaPath2()
public long SetProgramNcaPath2(ServiceCtx context)
public ResultCode SetProgramNcaPath2(ServiceCtx context)
{
long titleId = context.RequestData.ReadInt64();
RedirectPath(context, titleId, 1, ContentType.Program);
return 0;
return ResultCode.Success;
}
[Command(11)]
// ClearLocationResolver2()
public long ClearLocationResolver2(ServiceCtx context)
public ResultCode ClearLocationResolver2(ServiceCtx context)
{
context.Device.System.ContentManager.RefreshEntries(_storageId, 1);
return 0;
return ResultCode.Success;
}
[Command(12)]
// DeleteProgramNcaPath()
public long DeleteProgramNcaPath(ServiceCtx context)
public ResultCode DeleteProgramNcaPath(ServiceCtx context)
{
long titleId = context.RequestData.ReadInt64();
DeleteContentPath(context, titleId, ContentType.Program);
return 0;
return ResultCode.Success;
}
[Command(13)]
// DeleteControlNcaPath()
public long DeleteControlNcaPath(ServiceCtx context)
public ResultCode DeleteControlNcaPath(ServiceCtx context)
{
long titleId = context.RequestData.ReadInt64();
DeleteContentPath(context, titleId, ContentType.Control);
return 0;
return ResultCode.Success;
}
[Command(14)]
// DeleteDocHtmlNcaPath()
public long DeleteDocHtmlNcaPath(ServiceCtx context)
public ResultCode DeleteDocHtmlNcaPath(ServiceCtx context)
{
long titleId = context.RequestData.ReadInt64();
DeleteContentPath(context, titleId, ContentType.Manual);
return 0;
return ResultCode.Success;
}
[Command(15)]
// DeleteInfoHtmlNcaPath()
public long DeleteInfoHtmlNcaPath(ServiceCtx context)
public ResultCode DeleteInfoHtmlNcaPath(ServiceCtx context)
{
long titleId = context.RequestData.ReadInt64();
DeleteContentPath(context, titleId, ContentType.Manual);
return 0;
return ResultCode.Success;
}
private void RedirectPath(ServiceCtx context, long titleId, int flag, ContentType contentType)

View File

@ -9,13 +9,13 @@ namespace Ryujinx.HLE.HOS.Services.Lr
[Command(0)]
// OpenLocationResolver()
private long OpenLocationResolver(ServiceCtx context)
private ResultCode OpenLocationResolver(ServiceCtx context)
{
StorageId storageId = (StorageId)context.RequestData.ReadByte();
MakeObject(context, new ILocationResolver(storageId));
return 0;
return ResultCode.Success;
}
}
}

View File

@ -1,8 +0,0 @@
namespace Ryujinx.HLE.HOS.Services.Lr
{
class LrErr
{
public const int ProgramLocationEntryNotFound = 2;
public const int AccessDenied = 5;
}
}

View File

@ -0,0 +1,13 @@
namespace Ryujinx.HLE.HOS.Services.Lr
{
enum ResultCode
{
ModuleId = 8,
ErrorCodeShift = 9,
Success = 0,
ProgramLocationEntryNotFound = (2 << ErrorCodeShift) | ModuleId,
AccessDenied = (5 << ErrorCodeShift) | ModuleId
}
}

View File

@ -9,7 +9,7 @@ namespace Ryujinx.HLE.HOS.Services.Mm
[Command(0)]
// InitializeOld(u32, u32, u32)
public long InitializeOld(ServiceCtx context)
public ResultCode InitializeOld(ServiceCtx context)
{
int unknown0 = context.RequestData.ReadInt32();
int unknown1 = context.RequestData.ReadInt32();
@ -17,35 +17,35 @@ namespace Ryujinx.HLE.HOS.Services.Mm
Logger.PrintStub(LogClass.ServiceMm, new { unknown0, unknown1, unknown2 });
return 0;
return ResultCode.Success;
}
[Command(1)]
// FinalizeOld(u32)
public long FinalizeOld(ServiceCtx context)
public ResultCode FinalizeOld(ServiceCtx context)
{
context.Device.Gpu.UninitializeVideoDecoder();
Logger.PrintStub(LogClass.ServiceMm);
return 0;
return ResultCode.Success;
}
[Command(2)]
// SetAndWaitOld(u32, u32, u32)
public long SetAndWaitOld(ServiceCtx context)
public ResultCode SetAndWaitOld(ServiceCtx context)
{
int unknown0 = context.RequestData.ReadInt32();
int unknown1 = context.RequestData.ReadInt32();
int unknown2 = context.RequestData.ReadInt32();
Logger.PrintStub(LogClass.ServiceMm, new { unknown0, unknown1, unknown2 });
return 0;
return ResultCode.Success;
}
[Command(3)]
// GetOld(u32) -> u32
public long GetOld(ServiceCtx context)
public ResultCode GetOld(ServiceCtx context)
{
int unknown0 = context.RequestData.ReadInt32();
@ -53,32 +53,32 @@ namespace Ryujinx.HLE.HOS.Services.Mm
context.ResponseData.Write(0);
return 0;
return ResultCode.Success;
}
[Command(4)]
// Initialize()
public long Initialize(ServiceCtx context)
public ResultCode Initialize(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceMm);
return 0;
return ResultCode.Success;
}
[Command(5)]
// Finalize(u32)
public long Finalize(ServiceCtx context)
public ResultCode Finalize(ServiceCtx context)
{
context.Device.Gpu.UninitializeVideoDecoder();
Logger.PrintStub(LogClass.ServiceMm);
return 0;
return ResultCode.Success;
}
[Command(6)]
// SetAndWait(u32, u32, u32)
public long SetAndWait(ServiceCtx context)
public ResultCode SetAndWait(ServiceCtx context)
{
int unknown0 = context.RequestData.ReadInt32();
int unknown1 = context.RequestData.ReadInt32();
@ -86,12 +86,12 @@ namespace Ryujinx.HLE.HOS.Services.Mm
Logger.PrintStub(LogClass.ServiceMm, new { unknown0, unknown1, unknown2 });
return 0;
return ResultCode.Success;
}
[Command(7)]
// Get(u32) -> u32
public long Get(ServiceCtx context)
public ResultCode Get(ServiceCtx context)
{
int unknown0 = context.RequestData.ReadInt32();
@ -99,7 +99,7 @@ namespace Ryujinx.HLE.HOS.Services.Mm
context.ResponseData.Write(0);
return 0;
return ResultCode.Success;
}
}
}

View File

@ -21,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
[Command(0)]
// Initialize(u64, u64, pid, buffer<unknown, 5>)
public long Initialize(ServiceCtx context)
public ResultCode Initialize(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
long mcuVersionData = context.RequestData.ReadInt64();
@ -50,12 +50,12 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
_state = State.Initialized;
return 0;
return ResultCode.Success;
}
[Command(1)]
// Finalize()
public long Finalize(ServiceCtx context)
public ResultCode Finalize(ServiceCtx context)
{
// TODO: Call StopDetection() and Unmount() when they will be implemented.
// Remove the instance of nn::nfc::server::Manager when it will be implemented.
@ -65,16 +65,16 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
_state = State.NonInitialized;
return 0;
return ResultCode.Success;
}
[Command(2)]
// ListDevices() -> (u32, buffer<unknown, 0xa>)
public long ListDevices(ServiceCtx context)
public ResultCode ListDevices(ServiceCtx context)
{
if (context.Request.RecvListBuff.Count == 0)
{
return ErrorCode.MakeError(ErrorModule.Nfp, NfpError.DevicesBufferIsNull);
return ResultCode.DevicesBufferIsNull;
}
long outputPosition = context.Request.RecvListBuff[0].Position;
@ -82,7 +82,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
if (_devices.Count == 0)
{
return ErrorCode.MakeError(ErrorModule.Nfp, NfpError.DeviceNotFound);
return ResultCode.DeviceNotFound;
}
for (int i = 0; i < _devices.Count; i++)
@ -92,110 +92,110 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
context.ResponseData.Write(_devices.Count);
return 0;
return ResultCode.Success;
}
[Command(3)]
// StartDetection(bytes<8, 4>)
public long StartDetection(ServiceCtx context)
public ResultCode StartDetection(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
[Command(4)]
// StopDetection(bytes<8, 4>)
public long StopDetection(ServiceCtx context)
public ResultCode StopDetection(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
[Command(5)]
// Mount(bytes<8, 4>, u32, u32)
public long Mount(ServiceCtx context)
public ResultCode Mount(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
[Command(6)]
// Unmount(bytes<8, 4>)
public long Unmount(ServiceCtx context)
public ResultCode Unmount(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
[Command(7)]
// OpenApplicationArea(bytes<8, 4>, u32)
public long OpenApplicationArea(ServiceCtx context)
public ResultCode OpenApplicationArea(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
[Command(8)]
// GetApplicationArea(bytes<8, 4>) -> (u32, buffer<unknown, 6>)
public long GetApplicationArea(ServiceCtx context)
public ResultCode GetApplicationArea(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
[Command(9)]
// SetApplicationArea(bytes<8, 4>, buffer<unknown, 5>)
public long SetApplicationArea(ServiceCtx context)
public ResultCode SetApplicationArea(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
[Command(10)]
// Flush(bytes<8, 4>)
public long Flush(ServiceCtx context)
public ResultCode Flush(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
[Command(11)]
// Restore(bytes<8, 4>)
public long Restore(ServiceCtx context)
public ResultCode Restore(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
[Command(12)]
// CreateApplicationArea(bytes<8, 4>, u32, buffer<unknown, 5>)
public long CreateApplicationArea(ServiceCtx context)
public ResultCode CreateApplicationArea(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
[Command(13)]
// GetTagInfo(bytes<8, 4>) -> buffer<unknown<0x58>, 0x1a>
public long GetTagInfo(ServiceCtx context)
public ResultCode GetTagInfo(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
[Command(14)]
// GetRegisterInfo(bytes<8, 4>) -> buffer<unknown<0x100>, 0x1a>
public long GetRegisterInfo(ServiceCtx context)
public ResultCode GetRegisterInfo(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
[Command(15)]
// GetCommonInfo(bytes<8, 4>) -> buffer<unknown<0x40>, 0x1a>
public long GetCommonInfo(ServiceCtx context)
public ResultCode GetCommonInfo(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
[Command(16)]
// GetModelInfo(bytes<8, 4>) -> buffer<unknown<0x40>, 0x1a>
public long GetModelInfo(ServiceCtx context)
public ResultCode GetModelInfo(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
[Command(17)]
// AttachActivateEvent(bytes<8, 4>) -> handle<copy>
public long AttachActivateEvent(ServiceCtx context)
public ResultCode AttachActivateEvent(ServiceCtx context)
{
uint deviceHandle = context.RequestData.ReadUInt32();
@ -215,16 +215,16 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_devices[i].ActivateEventHandle);
return 0;
return ResultCode.Success;
}
}
return ErrorCode.MakeError(ErrorModule.Nfp, NfpError.DeviceNotFound);
return ResultCode.DeviceNotFound;
}
[Command(18)]
// AttachDeactivateEvent(bytes<8, 4>) -> handle<copy>
public long AttachDeactivateEvent(ServiceCtx context)
public ResultCode AttachDeactivateEvent(ServiceCtx context)
{
uint deviceHandle = context.RequestData.ReadUInt32();
@ -244,25 +244,25 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_devices[i].DeactivateEventHandle);
return 0;
return ResultCode.Success;
}
}
return ErrorCode.MakeError(ErrorModule.Nfp, NfpError.DeviceNotFound);
return ResultCode.DeviceNotFound;
}
[Command(19)]
// GetState() -> u32
public long GetState(ServiceCtx context)
public ResultCode GetState(ServiceCtx context)
{
context.ResponseData.Write((int)_state);
return 0;
return ResultCode.Success;
}
[Command(20)]
// GetDeviceState(bytes<8, 4>) -> u32
public long GetDeviceState(ServiceCtx context)
public ResultCode GetDeviceState(ServiceCtx context)
{
uint deviceHandle = context.RequestData.ReadUInt32();
@ -272,18 +272,18 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
{
context.ResponseData.Write((uint)_devices[i].State);
return 0;
return ResultCode.Success;
}
}
context.ResponseData.Write((uint)DeviceState.Unavailable);
return ErrorCode.MakeError(ErrorModule.Nfp, NfpError.DeviceNotFound);
return ResultCode.DeviceNotFound;
}
[Command(21)]
// GetNpadId(bytes<8, 4>) -> u32
public long GetNpadId(ServiceCtx context)
public ResultCode GetNpadId(ServiceCtx context)
{
uint deviceHandle = context.RequestData.ReadUInt32();
@ -293,23 +293,23 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
{
context.ResponseData.Write((uint)HidUtils.GetNpadIdTypeFromIndex(_devices[i].Handle));
return 0;
return ResultCode.Success;
}
}
return ErrorCode.MakeError(ErrorModule.Nfp, NfpError.DeviceNotFound);
return ResultCode.DeviceNotFound;
}
[Command(22)]
// GetApplicationAreaSize(bytes<8, 4>) -> u32
public long GetApplicationAreaSize(ServiceCtx context)
public ResultCode GetApplicationAreaSize(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}
[Command(23)] // 3.0.0+
// AttachAvailabilityChangeEvent() -> handle<copy>
public long AttachAvailabilityChangeEvent(ServiceCtx context)
public ResultCode AttachAvailabilityChangeEvent(ServiceCtx context)
{
if (_availabilityChangeEventHandle == 0)
{
@ -323,12 +323,12 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_availabilityChangeEventHandle);
return 0;
return ResultCode.Success;
}
[Command(24)] // 3.0.0+
// RecreateApplicationArea(bytes<8, 4>, u32, buffer<unknown, 5>)
public long RecreateApplicationArea(ServiceCtx context)
public ResultCode RecreateApplicationArea(ServiceCtx context)
{
throw new ServiceNotImplementedException(context);
}

View File

@ -7,11 +7,11 @@
[Command(0)]
// CreateUserInterface() -> object<nn::nfp::detail::IUser>
public long GetUserInterface(ServiceCtx context)
public ResultCode GetUserInterface(ServiceCtx context)
{
MakeObject(context, new IUser());
return 0;
return ResultCode.Success;
}
}
}

View File

@ -1,8 +0,0 @@
namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
{
static class NfpError
{
public const int DeviceNotFound = 64;
public const int DevicesBufferIsNull = 65;
}
}

View File

@ -0,0 +1,13 @@
namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
{
public enum ResultCode
{
ModuleId = 115,
ErrorCodeShift = 9,
Success = 0,
DeviceNotFound = (64 << ErrorCodeShift) | ModuleId,
DevicesBufferIsNull = (65 << ErrorCodeShift) | ModuleId
}
}

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;
}
}

Some files were not shown because too many files have changed in this diff Show More