fs.mitm: Use enum class some more

This commit is contained in:
Tony Wasserka 2018-06-16 17:09:00 +02:00
parent 4d2096d685
commit 0b41d57b0c
3 changed files with 28 additions and 24 deletions

View File

@ -5,13 +5,13 @@
#include "debug.hpp" #include "debug.hpp"
enum FsIStorageCmd { enum class FsIStorageCmd {
FsIStorage_Cmd_Read = 0, Read = 0,
FsIStorage_Cmd_Write = 1, Write = 1,
FsIStorage_Cmd_Flush = 2, Flush = 2,
FsIStorage_Cmd_SetSize = 3, SetSize = 3,
FsIStorage_Cmd_GetSize = 4, GetSize = 4,
FsIStorage_Cmd_OperateRange = 5, OperateRange = 5,
}; };
class IStorage { class IStorage {
@ -49,22 +49,22 @@ class IStorageInterface : public IServiceObject {
Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) final { Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) final {
Result rc = 0xF601; Result rc = 0xF601;
switch ((FsIStorageCmd)cmd_id) { switch ((FsIStorageCmd)cmd_id) {
case FsIStorage_Cmd_Read: case FsIStorageCmd::Read:
rc = WrapIpcCommandImpl<&IStorageInterface::read>(this, r, out_c, pointer_buffer, pointer_buffer_size); rc = WrapIpcCommandImpl<&IStorageInterface::read>(this, r, out_c, pointer_buffer, pointer_buffer_size);
break; break;
case FsIStorage_Cmd_Write: case FsIStorageCmd::Write:
rc = WrapIpcCommandImpl<&IStorageInterface::write>(this, r, out_c, pointer_buffer, pointer_buffer_size); rc = WrapIpcCommandImpl<&IStorageInterface::write>(this, r, out_c, pointer_buffer, pointer_buffer_size);
break; break;
case FsIStorage_Cmd_Flush: case FsIStorageCmd::Flush:
rc = WrapIpcCommandImpl<&IStorageInterface::flush>(this, r, out_c, pointer_buffer, pointer_buffer_size); rc = WrapIpcCommandImpl<&IStorageInterface::flush>(this, r, out_c, pointer_buffer, pointer_buffer_size);
break; break;
case FsIStorage_Cmd_SetSize: case FsIStorageCmd::SetSize:
rc = WrapIpcCommandImpl<&IStorageInterface::set_size>(this, r, out_c, pointer_buffer, pointer_buffer_size); rc = WrapIpcCommandImpl<&IStorageInterface::set_size>(this, r, out_c, pointer_buffer, pointer_buffer_size);
break; break;
case FsIStorage_Cmd_GetSize: case FsIStorageCmd::GetSize:
rc = WrapIpcCommandImpl<&IStorageInterface::get_size>(this, r, out_c, pointer_buffer, pointer_buffer_size); rc = WrapIpcCommandImpl<&IStorageInterface::get_size>(this, r, out_c, pointer_buffer, pointer_buffer_size);
break; break;
case FsIStorage_Cmd_OperateRange: case FsIStorageCmd::OperateRange:
if (kernelAbove400()) { if (kernelAbove400()) {
rc = WrapIpcCommandImpl<&IStorageInterface::operate_range>(this, r, out_c, pointer_buffer, pointer_buffer_size); rc = WrapIpcCommandImpl<&IStorageInterface::operate_range>(this, r, out_c, pointer_buffer, pointer_buffer_size);
} }

View File

@ -13,16 +13,18 @@
Result FsMitMService::dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) { Result FsMitMService::dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) {
Result rc = 0xF601; Result rc = 0xF601;
if (this->has_initialized) { if (this->has_initialized) {
switch (cmd_id) { switch (static_cast<FspSrvCmd>(cmd_id)) {
case FspSrv_Cmd_OpenDataStorageByCurrentProcess: case FspSrvCmd::OpenDataStorageByCurrentProcess:
rc = WrapIpcCommandImpl<&FsMitMService::open_data_storage_by_current_process>(this, r, out_c, pointer_buffer, pointer_buffer_size); rc = WrapIpcCommandImpl<&FsMitMService::open_data_storage_by_current_process>(this, r, out_c, pointer_buffer, pointer_buffer_size);
break; break;
case FspSrv_Cmd_OpenDataStorageByDataId: case FspSrvCmd::OpenDataStorageByDataId:
rc = WrapIpcCommandImpl<&FsMitMService::open_data_storage_by_data_id>(this, r, out_c, pointer_buffer, pointer_buffer_size); rc = WrapIpcCommandImpl<&FsMitMService::open_data_storage_by_data_id>(this, r, out_c, pointer_buffer, pointer_buffer_size);
break; break;
default:
break;
} }
} else { } else {
if (cmd_id == FspSrv_Cmd_SetCurrentProcess) { if (static_cast<FspSrvCmd>(cmd_id) == FspSrvCmd::SetCurrentProcess) {
if (r.HasPid) { if (r.HasPid) {
this->init_pid = r.Pid; this->init_pid = r.Pid;
} }
@ -44,8 +46,8 @@ void FsMitMService::postprocess(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_
} }
Result rc = (Result)resp->result; Result rc = (Result)resp->result;
switch (cmd_id) { switch (static_cast<FspSrvCmd>(cmd_id)) {
case FspSrv_Cmd_SetCurrentProcess: case FspSrvCmd::SetCurrentProcess:
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
this->has_initialized = true; this->has_initialized = true;
} }
@ -58,6 +60,8 @@ void FsMitMService::postprocess(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_
tls[i] = backup_tls[i]; tls[i] = backup_tls[i];
} }
break; break;
default:
break;
} }
resp->result = rc; resp->result = rc;
} }

View File

@ -4,10 +4,10 @@
#include "imitmserviceobject.hpp" #include "imitmserviceobject.hpp"
#include "fs_istorage.hpp" #include "fs_istorage.hpp"
enum FspSrvCmd { enum class FspSrvCmd {
FspSrv_Cmd_SetCurrentProcess = 1, SetCurrentProcess = 1,
FspSrv_Cmd_OpenDataStorageByCurrentProcess = 200, OpenDataStorageByCurrentProcess = 200,
FspSrv_Cmd_OpenDataStorageByDataId = 202, OpenDataStorageByDataId = 202,
}; };
class FsMitMService : public IMitMServiceObject { class FsMitMService : public IMitMServiceObject {
@ -43,4 +43,4 @@ class FsMitMService : public IMitMServiceObject {
/* Overridden commands. */ /* Overridden commands. */
std::tuple<Result, OutSession<IStorageInterface>> open_data_storage_by_current_process(); std::tuple<Result, OutSession<IStorageInterface>> open_data_storage_by_current_process();
std::tuple<Result, OutSession<IStorageInterface>> open_data_storage_by_data_id(u64 storage_id, u64 data_id); std::tuple<Result, OutSession<IStorageInterface>> open_data_storage_by_data_id(u64 storage_id, u64 data_id);
}; };