From 2e0ac9bdd57f7949a4450ad73a670b82dd7e8a92 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Mon, 17 Feb 2020 14:50:53 +0000 Subject: [PATCH] Refactor fatal services Use the new service naming convention. --- app/CMakeLists.txt | 2 +- .../main/cpp/skyline/services/base_service.h | 4 ++-- .../main/cpp/skyline/services/fatal/fatal.cpp | 13 ------------- .../main/cpp/skyline/services/fatal/fatal.h | 19 ------------------- .../skyline/services/fatalsrv/IService.cpp | 13 +++++++++++++ .../cpp/skyline/services/fatalsrv/IService.h | 19 +++++++++++++++++++ .../main/cpp/skyline/services/serviceman.cpp | 6 +++--- 7 files changed, 38 insertions(+), 38 deletions(-) delete mode 100644 app/src/main/cpp/skyline/services/fatal/fatal.cpp delete mode 100644 app/src/main/cpp/skyline/services/fatal/fatal.h create mode 100644 app/src/main/cpp/skyline/services/fatalsrv/IService.cpp create mode 100644 app/src/main/cpp/skyline/services/fatalsrv/IService.h diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index c06a6318..b6160b3b 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -51,7 +51,7 @@ add_library(skyline SHARED ${source_DIR}/skyline/kernel/types/KPrivateMemory.cpp ${source_DIR}/skyline/services/serviceman.cpp ${source_DIR}/skyline/services/sm/IUserInterface.cpp - ${source_DIR}/skyline/services/fatal/fatal.cpp + ${source_DIR}/skyline/services/fatalsrv/IService.cpp ${source_DIR}/skyline/services/audout/audout.cpp ${source_DIR}/skyline/services/audren/IAudioRendererManager.cpp ${source_DIR}/skyline/services/audren/IAudioRenderer.cpp diff --git a/app/src/main/cpp/skyline/services/base_service.h b/app/src/main/cpp/skyline/services/base_service.h index 9145791f..cf8d44be 100644 --- a/app/src/main/cpp/skyline/services/base_service.h +++ b/app/src/main/cpp/skyline/services/base_service.h @@ -19,7 +19,7 @@ namespace skyline::service { */ enum class Service { sm_IUserInterface, - fatal_u, + fatalsrv_IService, settings_ISystemSettingsServer, apm, apm_ISession, @@ -61,7 +61,7 @@ namespace skyline::service { * @brief A map from every service's name as a std::string to the corresponding serviceEnum */ const static std::unordered_map ServiceString{ - {"fatal:u", Service::fatal_u}, + {"fatal:u", Service::fatalsrv_IService}, {"set:sys", Service::settings_ISystemSettingsServer}, {"apm", Service::apm}, {"appletOE", Service::am_appletOE}, diff --git a/app/src/main/cpp/skyline/services/fatal/fatal.cpp b/app/src/main/cpp/skyline/services/fatal/fatal.cpp deleted file mode 100644 index be22f931..00000000 --- a/app/src/main/cpp/skyline/services/fatal/fatal.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "fatal.h" - -namespace skyline::service::fatal { - fatalU::fatalU(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::fatal_u, "fatal:u", { - {0x0, SFUNC(fatalU::ThrowFatal)}, - {0x1, SFUNC(fatalU::ThrowFatal)}, - {0x2, SFUNC(fatalU::ThrowFatal)} - }) {} - - void fatalU::ThrowFatal(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - throw exception("A fatal error with code: 0x{:X} has caused emulation to stop", *reinterpret_cast(request.cmdArg)); - } -} diff --git a/app/src/main/cpp/skyline/services/fatal/fatal.h b/app/src/main/cpp/skyline/services/fatal/fatal.h deleted file mode 100644 index 56e70767..00000000 --- a/app/src/main/cpp/skyline/services/fatal/fatal.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include -#include - -namespace skyline::service::fatal { - /** - * @brief fatal_u is used by applications to throw errors (https://switchbrew.org/wiki/Fatal_services#fatal:u) - */ - class fatalU : public BaseService { - public: - fatalU(const DeviceState &state, ServiceManager &manager); - - /** - * @brief This throws an exception so that emulation will quit - */ - void ThrowFatal(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - }; -} diff --git a/app/src/main/cpp/skyline/services/fatalsrv/IService.cpp b/app/src/main/cpp/skyline/services/fatalsrv/IService.cpp new file mode 100644 index 00000000..fe03500a --- /dev/null +++ b/app/src/main/cpp/skyline/services/fatalsrv/IService.cpp @@ -0,0 +1,13 @@ +#include "IService.h" + +namespace skyline::service::fatalsrv { + IService::IService(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::fatalsrv_IService, "fatalsrv:IService", { + {0x0, SFUNC(IService::ThrowFatal)}, + {0x1, SFUNC(IService::ThrowFatal)}, + {0x2, SFUNC(IService::ThrowFatal)} + }) {} + + void IService::ThrowFatal(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + throw exception("A fatal error with code: 0x{:X} has caused emulation to stop", *reinterpret_cast(request.cmdArg)); + } +} diff --git a/app/src/main/cpp/skyline/services/fatalsrv/IService.h b/app/src/main/cpp/skyline/services/fatalsrv/IService.h new file mode 100644 index 00000000..f4ea4e84 --- /dev/null +++ b/app/src/main/cpp/skyline/services/fatalsrv/IService.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include + +namespace skyline::service::fatalsrv { + /** + * @brief IService or fatal:u is used by applications to throw errors (https://switchbrew.org/wiki/Fatal_services#fatal:u) + */ + class IService : public BaseService { + public: + IService(const DeviceState &state, ServiceManager &manager); + + /** + * @brief This throws an exception that causes emulation to quit + */ + void ThrowFatal(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + }; +} diff --git a/app/src/main/cpp/skyline/services/serviceman.cpp b/app/src/main/cpp/skyline/services/serviceman.cpp index cedbe642..0718664e 100644 --- a/app/src/main/cpp/skyline/services/serviceman.cpp +++ b/app/src/main/cpp/skyline/services/serviceman.cpp @@ -6,7 +6,7 @@ #include "am/applet.h" #include "am/appletController.h" #include "audout/audout.h" -#include "fatal/fatal.h" +#include "fatalsrv/IService.h" #include "hid/IHidServer.h" #include "timesrv/IStaticService.h" #include "fssrv/IFileSystemProxy.h" @@ -26,8 +26,8 @@ namespace skyline::service { case Service::sm_IUserInterface: serviceObj = std::make_shared(state, *this); break; - case Service::fatal_u: - serviceObj = std::make_shared(state, *this); + case Service::fatalsrv_IService: + serviceObj = std::make_shared(state, *this); break; case Service::settings_ISystemSettingsServer: serviceObj = std::make_shared(state, *this);