Refactoring commands handling (#728)
* Refactoring commands handling - Use Reflection to handle commands ID. - Add all symbols (from SwIPC so not all time accurate). - Re-sort some services commands methods. - Some cleanup. - Keep some empty constructor for consistency. * Fix order in IProfile
This commit is contained in:
parent
f723f6f39a
commit
560ccbeb2d
99 changed files with 1035 additions and 1983 deletions
|
@ -1,5 +1,4 @@
|
|||
using LibHac;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
|
@ -9,27 +8,17 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
{
|
||||
private const int DirectoryEntrySize = 0x310;
|
||||
|
||||
private Dictionary<int, ServiceProcessRequest> _commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
||||
|
||||
private IEnumerator<LibHac.Fs.DirectoryEntry> _enumerator;
|
||||
|
||||
private LibHac.Fs.IDirectory _baseDirectory;
|
||||
|
||||
public IDirectory(LibHac.Fs.IDirectory directory)
|
||||
{
|
||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||
{
|
||||
{ 0, Read },
|
||||
{ 1, GetEntryCount }
|
||||
};
|
||||
|
||||
_baseDirectory = directory;
|
||||
|
||||
_enumerator = directory.Read().GetEnumerator();
|
||||
_enumerator = directory.Read().GetEnumerator();
|
||||
}
|
||||
|
||||
[Command(0)]
|
||||
// Read() -> (u64 count, buffer<nn::fssrv::sf::IDirectoryEntry, 6, 0> entries)
|
||||
public long Read(ServiceCtx context)
|
||||
{
|
||||
|
@ -76,6 +65,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
context.Memory.WriteInt64(position + 0x308, entry.Size);
|
||||
}
|
||||
|
||||
[Command(1)]
|
||||
// GetEntryCount() -> u64
|
||||
public long GetEntryCount(ServiceCtx context)
|
||||
{
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
using LibHac;
|
||||
using LibHac.Fs;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||
{
|
||||
class IFile : IpcService, IDisposable
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> _commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
||||
|
||||
private LibHac.Fs.IFile _baseFile;
|
||||
|
||||
public IFile(LibHac.Fs.IFile baseFile)
|
||||
{
|
||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||
{
|
||||
{ 0, Read },
|
||||
{ 1, Write },
|
||||
{ 2, Flush },
|
||||
{ 3, SetSize },
|
||||
{ 4, GetSize }
|
||||
};
|
||||
|
||||
_baseFile = baseFile;
|
||||
}
|
||||
|
||||
[Command(0)]
|
||||
// Read(u32 readOption, u64 offset, u64 size) -> (u64 out_size, buffer<u8, 0x46, 0> out_buf)
|
||||
public long Read(ServiceCtx context)
|
||||
{
|
||||
|
@ -58,6 +44,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(1)]
|
||||
// Write(u32 writeOption, u64 offset, u64 size, buffer<u8, 0x45, 0>)
|
||||
public long Write(ServiceCtx context)
|
||||
{
|
||||
|
@ -83,6 +70,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(2)]
|
||||
// Flush()
|
||||
public long Flush(ServiceCtx context)
|
||||
{
|
||||
|
@ -98,6 +86,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(3)]
|
||||
// SetSize(u64 size)
|
||||
public long SetSize(ServiceCtx context)
|
||||
{
|
||||
|
@ -115,6 +104,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(4)]
|
||||
// GetSize() -> u64 fileSize
|
||||
public long GetSize(ServiceCtx context)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
using LibHac;
|
||||
using LibHac.Fs;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using static Ryujinx.HLE.HOS.ErrorCode;
|
||||
using static Ryujinx.HLE.Utilities.StringUtils;
|
||||
|
@ -10,36 +8,14 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
{
|
||||
class IFileSystem : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> _commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
||||
|
||||
private LibHac.Fs.IFileSystem _fileSystem;
|
||||
|
||||
public IFileSystem(LibHac.Fs.IFileSystem provider)
|
||||
{
|
||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||
{
|
||||
{ 0, CreateFile },
|
||||
{ 1, DeleteFile },
|
||||
{ 2, CreateDirectory },
|
||||
{ 3, DeleteDirectory },
|
||||
{ 4, DeleteDirectoryRecursively },
|
||||
{ 5, RenameFile },
|
||||
{ 6, RenameDirectory },
|
||||
{ 7, GetEntryType },
|
||||
{ 8, OpenFile },
|
||||
{ 9, OpenDirectory },
|
||||
{ 10, Commit },
|
||||
{ 11, GetFreeSpaceSize },
|
||||
{ 12, GetTotalSpaceSize },
|
||||
{ 13, CleanDirectoryRecursively },
|
||||
{ 14, GetFileTimeStampRaw }
|
||||
};
|
||||
|
||||
_fileSystem = provider;
|
||||
}
|
||||
|
||||
[Command(0)]
|
||||
// CreateFile(u32 createOption, u64 size, buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public long CreateFile(ServiceCtx context)
|
||||
{
|
||||
|
@ -62,6 +38,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(1)]
|
||||
// DeleteFile(buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public long DeleteFile(ServiceCtx context)
|
||||
{
|
||||
|
@ -79,6 +56,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(2)]
|
||||
// CreateDirectory(buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public long CreateDirectory(ServiceCtx context)
|
||||
{
|
||||
|
@ -96,6 +74,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(3)]
|
||||
// DeleteDirectory(buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public long DeleteDirectory(ServiceCtx context)
|
||||
{
|
||||
|
@ -113,6 +92,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(4)]
|
||||
// DeleteDirectoryRecursively(buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public long DeleteDirectoryRecursively(ServiceCtx context)
|
||||
{
|
||||
|
@ -130,6 +110,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(5)]
|
||||
// RenameFile(buffer<bytes<0x301>, 0x19, 0x301> oldPath, buffer<bytes<0x301>, 0x19, 0x301> newPath)
|
||||
public long RenameFile(ServiceCtx context)
|
||||
{
|
||||
|
@ -148,6 +129,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(6)]
|
||||
// RenameDirectory(buffer<bytes<0x301>, 0x19, 0x301> oldPath, buffer<bytes<0x301>, 0x19, 0x301> newPath)
|
||||
public long RenameDirectory(ServiceCtx context)
|
||||
{
|
||||
|
@ -166,6 +148,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(7)]
|
||||
// GetEntryType(buffer<bytes<0x301>, 0x19, 0x301> path) -> nn::fssrv::sf::DirectoryEntryType
|
||||
public long GetEntryType(ServiceCtx context)
|
||||
{
|
||||
|
@ -192,6 +175,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(8)]
|
||||
// OpenFile(u32 mode, buffer<bytes<0x301>, 0x19, 0x301> path) -> object<nn::fssrv::sf::IFile> file
|
||||
public long OpenFile(ServiceCtx context)
|
||||
{
|
||||
|
@ -215,6 +199,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(9)]
|
||||
// OpenDirectory(u32 filter_flags, buffer<bytes<0x301>, 0x19, 0x301> path) -> object<nn::fssrv::sf::IDirectory> directory
|
||||
public long OpenDirectory(ServiceCtx context)
|
||||
{
|
||||
|
@ -238,6 +223,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(10)]
|
||||
// Commit()
|
||||
public long Commit(ServiceCtx context)
|
||||
{
|
||||
|
@ -253,6 +239,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(11)]
|
||||
// GetFreeSpaceSize(buffer<bytes<0x301>, 0x19, 0x301> path) -> u64 totalFreeSpace
|
||||
public long GetFreeSpaceSize(ServiceCtx context)
|
||||
{
|
||||
|
@ -270,6 +257,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(12)]
|
||||
// GetTotalSpaceSize(buffer<bytes<0x301>, 0x19, 0x301> path) -> u64 totalSize
|
||||
public long GetTotalSpaceSize(ServiceCtx context)
|
||||
{
|
||||
|
@ -287,6 +275,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(13)]
|
||||
// CleanDirectoryRecursively(buffer<bytes<0x301>, 0x19, 0x301> path)
|
||||
public long CleanDirectoryRecursively(ServiceCtx context)
|
||||
{
|
||||
|
@ -304,6 +293,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(14)]
|
||||
// GetFileTimeStampRaw(buffer<bytes<0x301>, 0x19, 0x301> path) -> bytes<0x20> timestamp
|
||||
public long GetFileTimeStampRaw(ServiceCtx context)
|
||||
{
|
||||
|
|
|
@ -4,9 +4,7 @@ using LibHac.Fs.NcaUtils;
|
|||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using Ryujinx.HLE.Utilities;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using static Ryujinx.HLE.FileSystem.VirtualFileSystem;
|
||||
|
@ -18,34 +16,16 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
[Service("fsp-srv")]
|
||||
class IFileSystemProxy : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> _commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
||||
|
||||
public IFileSystemProxy(ServiceCtx context)
|
||||
{
|
||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||
{
|
||||
{ 1, Initialize },
|
||||
{ 8, OpenFileSystemWithId },
|
||||
{ 11, OpenBisFileSystem },
|
||||
{ 18, OpenSdCardFileSystem },
|
||||
{ 51, OpenSaveDataFileSystem },
|
||||
{ 52, OpenSaveDataFileSystemBySystemSaveDataId },
|
||||
{ 200, OpenDataStorageByCurrentProcess },
|
||||
{ 202, OpenDataStorageByDataId },
|
||||
{ 203, OpenPatchDataStorageByCurrentProcess },
|
||||
{ 1005, GetGlobalAccessLogMode },
|
||||
{ 1006, OutputAccessLogToSdCard }
|
||||
};
|
||||
}
|
||||
public IFileSystemProxy(ServiceCtx context) { }
|
||||
|
||||
[Command(1)]
|
||||
// Initialize(u64, pid)
|
||||
public long Initialize(ServiceCtx context)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
[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)
|
||||
|
@ -80,6 +60,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return MakeError(ErrorModule.Fs, FsErr.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)
|
||||
{
|
||||
|
@ -112,6 +93,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(18)]
|
||||
// OpenSdCardFileSystem() -> object<nn::fssrv::sf::IFileSystem>
|
||||
public long OpenSdCardFileSystem(ServiceCtx context)
|
||||
{
|
||||
|
@ -124,18 +106,21 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(51)]
|
||||
// OpenSaveDataFileSystem(u8 save_data_space_id, nn::fssrv::sf::SaveStruct saveStruct) -> object<nn::fssrv::sf::IFileSystem> saveDataFs
|
||||
public long 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)
|
||||
{
|
||||
return LoadSaveDataFileSystem(context);
|
||||
}
|
||||
|
||||
[Command(200)]
|
||||
// OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage
|
||||
public long OpenDataStorageByCurrentProcess(ServiceCtx context)
|
||||
{
|
||||
|
@ -144,6 +129,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(202)]
|
||||
// OpenDataStorageByDataId(u8 storageId, nn::ApplicationId tid) -> object<nn::fssrv::sf::IStorage> dataStorage
|
||||
public long OpenDataStorageByDataId(ServiceCtx context)
|
||||
{
|
||||
|
@ -204,6 +190,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
throw new FileNotFoundException($"System archive with titleid {titleId:x16} was not found on Storage {storageId}. Found in {installedStorage}.");
|
||||
}
|
||||
|
||||
[Command(203)]
|
||||
// OpenPatchDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage>
|
||||
public long OpenPatchDataStorageByCurrentProcess(ServiceCtx context)
|
||||
{
|
||||
|
@ -212,6 +199,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(1005)]
|
||||
// GetGlobalAccessLogMode() -> u32 logMode
|
||||
public long GetGlobalAccessLogMode(ServiceCtx context)
|
||||
{
|
||||
|
@ -222,6 +210,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(1006)]
|
||||
// OutputAccessLogToSdCard(buffer<bytes, 5> log_text)
|
||||
public long OutputAccessLogToSdCard(ServiceCtx context)
|
||||
{
|
||||
|
|
|
@ -1,28 +1,18 @@
|
|||
using LibHac;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||
{
|
||||
class IStorage : IpcService
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> _commands;
|
||||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
||||
|
||||
private LibHac.Fs.IStorage _baseStorage;
|
||||
|
||||
public IStorage(LibHac.Fs.IStorage baseStorage)
|
||||
{
|
||||
_commands = new Dictionary<int, ServiceProcessRequest>
|
||||
{
|
||||
{ 0, Read },
|
||||
{ 4, GetSize }
|
||||
};
|
||||
|
||||
_baseStorage = baseStorage;
|
||||
}
|
||||
|
||||
[Command(0)]
|
||||
// Read(u64 offset, u64 length) -> buffer<u8, 0x46, 0> buffer
|
||||
public long Read(ServiceCtx context)
|
||||
{
|
||||
|
@ -56,6 +46,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
|
||||
[Command(4)]
|
||||
// GetSize() -> u64 size
|
||||
public long GetSize(ServiceCtx context)
|
||||
{
|
||||
|
@ -71,4 +62,4 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue