diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index cedd9eea..c06a6318 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -66,7 +66,8 @@ add_library(skyline SHARED ${source_DIR}/skyline/services/timesrv/IStaticService.cpp ${source_DIR}/skyline/services/timesrv/ISystemClock.cpp ${source_DIR}/skyline/services/timesrv/ITimeZoneService.cpp - ${source_DIR}/skyline/services/fs/fs.cpp + ${source_DIR}/skyline/services/fssrv/IFileSystemProxy.cpp + ${source_DIR}/skyline/services/fssrv/IFileSystem.cpp ${source_DIR}/skyline/services/nvdrv/nvdrv.cpp ${source_DIR}/skyline/services/nvnflinger/dispdrv.cpp ${source_DIR}/skyline/services/vi/vi_m.cpp diff --git a/app/src/main/cpp/skyline/services/base_service.h b/app/src/main/cpp/skyline/services/base_service.h index 49326dc9..9145791f 100644 --- a/app/src/main/cpp/skyline/services/base_service.h +++ b/app/src/main/cpp/skyline/services/base_service.h @@ -47,8 +47,8 @@ namespace skyline::service { timesrv_IStaticService, timesrv_ISystemClock, timesrv_ITimeZoneService, - fs_fsp, - fs_IFileSystem, + fssrv_IFileSystemProxy, + fssrv_IFileSystem, nvdrv, vi_m, vi_IApplicationDisplayService, @@ -72,7 +72,7 @@ namespace skyline::service { {"time:s", Service::timesrv_IStaticService}, {"time:a", Service::timesrv_IStaticService}, {"time:u", Service::timesrv_IStaticService}, - {"fsp-srv", Service::fs_fsp}, + {"fsp-srv", Service::fssrv_IFileSystemProxy}, {"nvdrv", Service::nvdrv}, {"nvdrv:a", Service::nvdrv}, {"nvdrv:s", Service::nvdrv}, diff --git a/app/src/main/cpp/skyline/services/fs/fs.cpp b/app/src/main/cpp/skyline/services/fs/fs.cpp deleted file mode 100644 index bc2cca34..00000000 --- a/app/src/main/cpp/skyline/services/fs/fs.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "fs.h" - -namespace skyline::service::fs { - fsp::fsp(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::fs_fsp, "fs:fsp", { - {0x1, SFUNC(fsp::SetCurrentProcess)}, - {0x12, SFUNC(fsp::OpenSdCardFileSystem)} - }) {} - - void fsp::SetCurrentProcess(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - process = *reinterpret_cast(request.cmdArg); - } - - void fsp::OpenSdCardFileSystem(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - manager.RegisterService(std::make_shared(FsType::SdCard, state, manager), session, response); - } - - IFileSystem::IFileSystem(FsType type, const DeviceState &state, ServiceManager &manager) : type(type), BaseService(state, manager, Service::fs_IFileSystem, "fs:IFileSystem", {}) {} -} diff --git a/app/src/main/cpp/skyline/services/fssrv/IFileSystem.cpp b/app/src/main/cpp/skyline/services/fssrv/IFileSystem.cpp new file mode 100644 index 00000000..02be4e05 --- /dev/null +++ b/app/src/main/cpp/skyline/services/fssrv/IFileSystem.cpp @@ -0,0 +1,5 @@ +#include "IFileSystem.h" + +namespace skyline::service::fssrv { + IFileSystem::IFileSystem(const FsType type, const DeviceState &state, ServiceManager &manager) : type(type), BaseService(state, manager, Service::fssrv_IFileSystem, "fssrv:IFileSystem", {}) {} +} diff --git a/app/src/main/cpp/skyline/services/fssrv/IFileSystem.h b/app/src/main/cpp/skyline/services/fssrv/IFileSystem.h new file mode 100644 index 00000000..28a85d11 --- /dev/null +++ b/app/src/main/cpp/skyline/services/fssrv/IFileSystem.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include + +namespace skyline::service::fssrv { + /** + * @brief These are the possible types of the filesystem + */ + enum class FsType { + Nand, + SdCard, + GameCard + }; + + /** + * @brief IFileSystem is used to interact with a filesystem (https://switchbrew.org/wiki/Filesystem_services#IFileSystem) + */ + class IFileSystem : public BaseService { + public: + const FsType type; + + IFileSystem(FsType type, const DeviceState &state, ServiceManager &manager); + }; +} diff --git a/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.cpp b/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.cpp new file mode 100644 index 00000000..aaa34116 --- /dev/null +++ b/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.cpp @@ -0,0 +1,16 @@ +#include "IFileSystemProxy.h" + +namespace skyline::service::fssrv { + IFileSystemProxy::IFileSystemProxy(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::fssrv_IFileSystemProxy, "fssrv:IFileSystemProxy", { + {0x1, SFUNC(IFileSystemProxy::SetCurrentProcess)}, + {0x12, SFUNC(IFileSystemProxy::OpenSdCardFileSystem)} + }) {} + + void IFileSystemProxy::SetCurrentProcess(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + process = *reinterpret_cast(request.cmdArg); + } + + void IFileSystemProxy::OpenSdCardFileSystem(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.RegisterService(std::make_shared(FsType::SdCard, state, manager), session, response); + } +} diff --git a/app/src/main/cpp/skyline/services/fs/fs.h b/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.h similarity index 55% rename from app/src/main/cpp/skyline/services/fs/fs.h rename to app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.h index 5b11de3d..ab0135e1 100644 --- a/app/src/main/cpp/skyline/services/fs/fs.h +++ b/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.h @@ -2,25 +2,17 @@ #include #include +#include "IFileSystem.h" -namespace skyline::service::fs { +namespace skyline::service::fssrv { /** - * @brief These are the possible types of the filesystem + * @brief IFileSystemProxy or fsp-srv is responsible for providing handles to file systems (https://switchbrew.org/wiki/Filesystem_services#fsp-srv) */ - enum class FsType { - Nand, - SdCard, - GameCard - }; - - /** - * @brief fsp-srv or IFileSystemProxy is responsible for providing handles to file systems (https://switchbrew.org/wiki/Filesystem_services#fsp-srv) - */ - class fsp : public BaseService { + class IFileSystemProxy : public BaseService { public: pid_t process{}; //!< This holds the PID set by SetCurrentProcess - fsp(const DeviceState &state, ServiceManager &manager); + IFileSystemProxy(const DeviceState &state, ServiceManager &manager); /** * @brief This sets the PID of the process using FS currently (https://switchbrew.org/wiki/Filesystem_services#SetCurrentProcess) @@ -32,14 +24,4 @@ namespace skyline::service::fs { */ void OpenSdCardFileSystem(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); }; - - /** - * @brief IFileSystem is used to interact with a filesystem (https://switchbrew.org/wiki/Filesystem_services#IFileSystem) - */ - class IFileSystem : public BaseService { - public: - FsType type; - - IFileSystem(FsType type, const DeviceState &state, ServiceManager &manager); - }; } diff --git a/app/src/main/cpp/skyline/services/serviceman.cpp b/app/src/main/cpp/skyline/services/serviceman.cpp index 61c885b6..cedbe642 100644 --- a/app/src/main/cpp/skyline/services/serviceman.cpp +++ b/app/src/main/cpp/skyline/services/serviceman.cpp @@ -9,7 +9,7 @@ #include "fatal/fatal.h" #include "hid/IHidServer.h" #include "timesrv/IStaticService.h" -#include "fs/fs.h" +#include "fssrv/IFileSystemProxy.h" #include "nvdrv/nvdrv.h" #include "vi/vi_m.h" #include "serviceman.h" @@ -53,8 +53,8 @@ namespace skyline::service { case Service::timesrv_IStaticService: serviceObj = std::make_shared(state, *this); break; - case Service::fs_fsp: - serviceObj = std::make_shared(state, *this); + case Service::fssrv_IFileSystemProxy: + serviceObj = std::make_shared(state, *this); break; case Service::nvdrv: serviceObj = std::make_shared(state, *this);