stratosphere: all in on enum class CommandId

This commit is contained in:
Michael Scire
2019-06-27 23:34:26 -07:00
parent 67c0f4527e
commit 18ca8aaf5b
38 changed files with 665 additions and 658 deletions

View File

@@ -18,11 +18,6 @@
#include <switch.h>
#include <stratosphere.hpp>
enum FsIDirectoryCmd : u32 {
FsIDirectoryCmd_Read = 0,
FsIDirectoryCmd_GetEntryCount = 1,
};
class IDirectory {
public:
virtual ~IDirectory() {}
@@ -56,6 +51,11 @@ class IDirectory {
};
class IDirectoryInterface : public IServiceObject {
private:
enum class CommandId {
Read = 0,
GetEntryCount = 1,
};
private:
std::unique_ptr<IDirectory> base_dir;
public:
@@ -77,8 +77,8 @@ class IDirectoryInterface : public IServiceObject {
public:
DEFINE_SERVICE_DISPATCH_TABLE {
/* 1.0.0- */
MakeServiceCommandMeta<FsIDirectoryCmd_Read, &IDirectoryInterface::Read>(),
MakeServiceCommandMeta<FsIDirectoryCmd_GetEntryCount, &IDirectoryInterface::GetEntryCount>(),
MAKE_SERVICE_COMMAND_META(IDirectoryInterface, Read),
MAKE_SERVICE_COMMAND_META(IDirectoryInterface, GetEntryCount),
};
};

View File

@@ -20,15 +20,6 @@
#include "fs_shim.h"
enum FsIFileCmd : u32 {
FsIFileCmd_Read = 0,
FsIFileCmd_Write = 1,
FsIFileCmd_Flush = 2,
FsIFileCmd_SetSize = 3,
FsIFileCmd_GetSize = 4,
FsIFileCmd_OperateRange = 5,
};
class IFile {
public:
virtual ~IFile() {}
@@ -106,6 +97,15 @@ class IFile {
};
class IFileInterface : public IServiceObject {
private:
enum class CommandId {
Read = 0,
Write = 1,
Flush = 2,
SetSize = 3,
GetSize = 4,
OperateRange = 5,
};
private:
std::unique_ptr<IFile> base_file;
public:
@@ -139,14 +139,14 @@ class IFileInterface : public IServiceObject {
public:
DEFINE_SERVICE_DISPATCH_TABLE {
/* 1.0.0- */
MakeServiceCommandMeta<FsIFileCmd_Read, &IFileInterface::Read>(),
MakeServiceCommandMeta<FsIFileCmd_Write, &IFileInterface::Write>(),
MakeServiceCommandMeta<FsIFileCmd_Flush, &IFileInterface::Flush>(),
MakeServiceCommandMeta<FsIFileCmd_SetSize, &IFileInterface::SetSize>(),
MakeServiceCommandMeta<FsIFileCmd_GetSize, &IFileInterface::GetSize>(),
MAKE_SERVICE_COMMAND_META(IFileInterface, Read),
MAKE_SERVICE_COMMAND_META(IFileInterface, Write),
MAKE_SERVICE_COMMAND_META(IFileInterface, Flush),
MAKE_SERVICE_COMMAND_META(IFileInterface, SetSize),
MAKE_SERVICE_COMMAND_META(IFileInterface, GetSize),
/* 4.0.0- */
MakeServiceCommandMeta<FsIFileCmd_OperateRange, &IFileInterface::OperateRange, FirmwareVersion_400>(),
MAKE_SERVICE_COMMAND_META(IFileInterface, OperateRange, FirmwareVersion_400),
};
};

View File

@@ -26,30 +26,6 @@
#include "fs_ifile.hpp"
#include "fs_idirectory.hpp"
enum FsIFileSystemCmd : u32 {
/* 1.0.0+ */
FsIFileSystemCmd_CreateFile = 0,
FsIFileSystemCmd_DeleteFile = 1,
FsIFileSystemCmd_CreateDirectory = 2,
FsIFileSystemCmd_DeleteDirectory = 3,
FsIFileSystemCmd_DeleteDirectoryRecursively = 4,
FsIFileSystemCmd_RenameFile = 5,
FsIFileSystemCmd_RenameDirectory = 6,
FsIFileSystemCmd_GetEntryType = 7,
FsIFileSystemCmd_OpenFile = 8,
FsIFileSystemCmd_OpenDirectory = 9,
FsIFileSystemCmd_Commit = 10,
FsIFileSystemCmd_GetFreeSpaceSize = 11,
FsIFileSystemCmd_GetTotalSpaceSize = 12,
/* 3.0.0+ */
FsIFileSystemCmd_CleanDirectoryRecursively = 13,
FsIFileSystemCmd_GetFileTimeStampRaw = 14,
/* 4.0.0+ */
FsIFileSystemCmd_QueryEntry = 15,
};
class IFile;
class IDirectory;
@@ -197,6 +173,30 @@ class IFileSystem {
};
class IFileSystemInterface : public IServiceObject {
private:
enum class CommandId {
/* 1.0.0+ */
CreateFile = 0,
DeleteFile = 1,
CreateDirectory = 2,
DeleteDirectory = 3,
DeleteDirectoryRecursively = 4,
RenameFile = 5,
RenameDirectory = 6,
GetEntryType = 7,
OpenFile = 8,
OpenDirectory = 9,
Commit = 10,
GetFreeSpaceSize = 11,
GetTotalSpaceSize = 12,
/* 3.0.0+ */
CleanDirectoryRecursively = 13,
GetFileTimeStampRaw = 14,
/* 4.0.0+ */
QueryEntry = 15,
};
private:
std::unique_ptr<IFileSystem> unique_fs;
std::shared_ptr<IFileSystem> shared_fs;
@@ -342,26 +342,26 @@ class IFileSystemInterface : public IServiceObject {
public:
DEFINE_SERVICE_DISPATCH_TABLE {
/* 1.0.0- */
MakeServiceCommandMeta<FsIFileSystemCmd_CreateFile, &IFileSystemInterface::CreateFile>(),
MakeServiceCommandMeta<FsIFileSystemCmd_DeleteFile, &IFileSystemInterface::DeleteFile>(),
MakeServiceCommandMeta<FsIFileSystemCmd_CreateDirectory, &IFileSystemInterface::CreateDirectory>(),
MakeServiceCommandMeta<FsIFileSystemCmd_DeleteDirectory, &IFileSystemInterface::DeleteDirectory>(),
MakeServiceCommandMeta<FsIFileSystemCmd_DeleteDirectoryRecursively, &IFileSystemInterface::DeleteDirectoryRecursively>(),
MakeServiceCommandMeta<FsIFileSystemCmd_RenameFile, &IFileSystemInterface::RenameFile>(),
MakeServiceCommandMeta<FsIFileSystemCmd_RenameDirectory, &IFileSystemInterface::RenameDirectory>(),
MakeServiceCommandMeta<FsIFileSystemCmd_GetEntryType, &IFileSystemInterface::GetEntryType>(),
MakeServiceCommandMeta<FsIFileSystemCmd_OpenFile, &IFileSystemInterface::OpenFile>(),
MakeServiceCommandMeta<FsIFileSystemCmd_OpenDirectory, &IFileSystemInterface::OpenDirectory>(),
MakeServiceCommandMeta<FsIFileSystemCmd_Commit, &IFileSystemInterface::Commit>(),
MakeServiceCommandMeta<FsIFileSystemCmd_GetFreeSpaceSize, &IFileSystemInterface::GetFreeSpaceSize>(),
MakeServiceCommandMeta<FsIFileSystemCmd_GetTotalSpaceSize, &IFileSystemInterface::GetTotalSpaceSize>(),
MAKE_SERVICE_COMMAND_META(IFileSystemInterface, CreateFile),
MAKE_SERVICE_COMMAND_META(IFileSystemInterface, DeleteFile),
MAKE_SERVICE_COMMAND_META(IFileSystemInterface, CreateDirectory),
MAKE_SERVICE_COMMAND_META(IFileSystemInterface, DeleteDirectory),
MAKE_SERVICE_COMMAND_META(IFileSystemInterface, DeleteDirectoryRecursively),
MAKE_SERVICE_COMMAND_META(IFileSystemInterface, RenameFile),
MAKE_SERVICE_COMMAND_META(IFileSystemInterface, RenameDirectory),
MAKE_SERVICE_COMMAND_META(IFileSystemInterface, GetEntryType),
MAKE_SERVICE_COMMAND_META(IFileSystemInterface, OpenFile),
MAKE_SERVICE_COMMAND_META(IFileSystemInterface, OpenDirectory),
MAKE_SERVICE_COMMAND_META(IFileSystemInterface, Commit),
MAKE_SERVICE_COMMAND_META(IFileSystemInterface, GetFreeSpaceSize),
MAKE_SERVICE_COMMAND_META(IFileSystemInterface, GetTotalSpaceSize),
/* 3.0.0- */
MakeServiceCommandMeta<FsIFileSystemCmd_CleanDirectoryRecursively, &IFileSystemInterface::CleanDirectoryRecursively, FirmwareVersion_300>(),
MakeServiceCommandMeta<FsIFileSystemCmd_GetFileTimeStampRaw, &IFileSystemInterface::GetFileTimeStampRaw, FirmwareVersion_300>(),
MAKE_SERVICE_COMMAND_META(IFileSystemInterface, CleanDirectoryRecursively, FirmwareVersion_300),
MAKE_SERVICE_COMMAND_META(IFileSystemInterface, GetFileTimeStampRaw, FirmwareVersion_300),
/* 4.0.0- */
MakeServiceCommandMeta<FsIFileSystemCmd_QueryEntry, &IFileSystemInterface::QueryEntry, FirmwareVersion_400>(),
MAKE_SERVICE_COMMAND_META(IFileSystemInterface, QueryEntry, FirmwareVersion_400),
};
};

View File

@@ -21,15 +21,6 @@
#include "../debug.hpp"
enum FsIStorageCmd : u32 {
FsIStorageCmd_Read = 0,
FsIStorageCmd_Write = 1,
FsIStorageCmd_Flush = 2,
FsIStorageCmd_SetSize = 3,
FsIStorageCmd_GetSize = 4,
FsIStorageCmd_OperateRange = 5,
};
class IStorage {
public:
virtual ~IStorage();
@@ -47,6 +38,15 @@ class IStorage {
};
class IStorageInterface : public IServiceObject {
private:
enum class CommandId {
Read = 0,
Write = 1,
Flush = 2,
SetSize = 3,
GetSize = 4,
OperateRange = 5,
};
private:
IStorage *base_storage;
public:
@@ -81,14 +81,14 @@ class IStorageInterface : public IServiceObject {
public:
DEFINE_SERVICE_DISPATCH_TABLE {
/* 1.0.0- */
MakeServiceCommandMeta<FsIStorageCmd_Read, &IStorageInterface::Read>(),
MakeServiceCommandMeta<FsIStorageCmd_Write, &IStorageInterface::Write>(),
MakeServiceCommandMeta<FsIStorageCmd_Flush, &IStorageInterface::Flush>(),
MakeServiceCommandMeta<FsIStorageCmd_SetSize, &IStorageInterface::SetSize>(),
MakeServiceCommandMeta<FsIStorageCmd_GetSize, &IStorageInterface::GetSize>(),
MAKE_SERVICE_COMMAND_META(IStorageInterface, Read),
MAKE_SERVICE_COMMAND_META(IStorageInterface, Write),
MAKE_SERVICE_COMMAND_META(IStorageInterface, Flush),
MAKE_SERVICE_COMMAND_META(IStorageInterface, SetSize),
MAKE_SERVICE_COMMAND_META(IStorageInterface, GetSize),
/* 4.0.0- */
MakeServiceCommandMeta<FsIStorageCmd_OperateRange, &IStorageInterface::OperateRange, FirmwareVersion_400>(),
MAKE_SERVICE_COMMAND_META(IStorageInterface, OperateRange, FirmwareVersion_400),
};
};

View File

@@ -69,8 +69,8 @@ static void StorageCacheSetEntry(u64 title_id, std::shared_ptr<IStorageInterface
void FsMitmService::PostProcess(IMitmServiceObject *obj, IpcResponseContext *ctx) {
auto this_ptr = static_cast<FsMitmService *>(obj);
switch ((FspSrvCmd)ctx->cmd_id) {
case FspSrvCmd_SetCurrentProcess:
switch (static_cast<CommandId>(ctx->cmd_id)) {
case CommandId::SetCurrentProcess:
if (R_SUCCEEDED(ctx->rc)) {
this_ptr->has_initialized = true;
this_ptr->process_id = ctx->request.Pid;

View File

@@ -21,24 +21,23 @@
#include "fs_ifilesystem.hpp"
#include "../utils.hpp"
enum FspSrvCmd : u32 {
FspSrvCmd_OpenFileSystemDeprecated = 0,
FspSrvCmd_SetCurrentProcess = 1,
FspSrvCmd_OpenFileSystemWithPatch = 7,
FspSrvCmd_OpenFileSystemWithId = 8,
FspSrvCmd_OpenSdCardFileSystem = 18,
FspSrvCmd_OpenSaveDataFileSystem = 51,
FspSrvCmd_OpenBisStorage = 12,
FspSrvCmd_OpenDataStorageByCurrentProcess = 200,
FspSrvCmd_OpenDataStorageByDataId = 202,
};
class FsMitmService : public IMitmServiceObject {
private:
enum class CommandId {
OpenFileSystemDeprecated = 0,
SetCurrentProcess = 1,
OpenFileSystemWithPatch = 7,
OpenFileSystemWithId = 8,
OpenSdCardFileSystem = 18,
OpenSaveDataFileSystem = 51,
OpenBisStorage = 12,
OpenDataStorageByCurrentProcess = 200,
OpenDataStorageByDataId = 202,
};
private:
static constexpr const char *AtmosphereHblWebContentDir = "/atmosphere/hbl_html";
private:
@@ -84,13 +83,13 @@ class FsMitmService : public IMitmServiceObject {
Result OpenDataStorageByDataId(Out<std::shared_ptr<IStorageInterface>> out, u64 data_id, u8 storage_id);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
/* TODO MakeServiceCommandMeta<FspSrvCmd_OpenFileSystemDeprecated, &FsMitmService::OpenFileSystemDeprecated>(), */
MakeServiceCommandMeta<FspSrvCmd_OpenFileSystemWithPatch, &FsMitmService::OpenFileSystemWithPatch, FirmwareVersion_200>(),
MakeServiceCommandMeta<FspSrvCmd_OpenFileSystemWithId, &FsMitmService::OpenFileSystemWithId, FirmwareVersion_200>(),
MakeServiceCommandMeta<FspSrvCmd_OpenSdCardFileSystem, &FsMitmService::OpenSdCardFileSystem>(),
MakeServiceCommandMeta<FspSrvCmd_OpenSaveDataFileSystem, &FsMitmService::OpenSaveDataFileSystem>(),
MakeServiceCommandMeta<FspSrvCmd_OpenBisStorage, &FsMitmService::OpenBisStorage>(),
MakeServiceCommandMeta<FspSrvCmd_OpenDataStorageByCurrentProcess, &FsMitmService::OpenDataStorageByCurrentProcess>(),
MakeServiceCommandMeta<FspSrvCmd_OpenDataStorageByDataId, &FsMitmService::OpenDataStorageByDataId>(),
/* TODO MAKE_SERVICE_COMMAND_META(FsMitmService, OpenFileSystemDeprecated), */
MAKE_SERVICE_COMMAND_META(FsMitmService, OpenFileSystemWithPatch, FirmwareVersion_200),
MAKE_SERVICE_COMMAND_META(FsMitmService, OpenFileSystemWithId, FirmwareVersion_200),
MAKE_SERVICE_COMMAND_META(FsMitmService, OpenSdCardFileSystem),
MAKE_SERVICE_COMMAND_META(FsMitmService, OpenSaveDataFileSystem),
MAKE_SERVICE_COMMAND_META(FsMitmService, OpenBisStorage),
MAKE_SERVICE_COMMAND_META(FsMitmService, OpenDataStorageByCurrentProcess),
MAKE_SERVICE_COMMAND_META(FsMitmService, OpenDataStorageByDataId),
};
};