Refactor fatal services

Use the new service naming convention.
This commit is contained in:
Billy Laws 2020-02-17 14:50:53 +00:00 committed by ◱ PixelyIon
parent 644cfbe332
commit 2e0ac9bdd5
7 changed files with 38 additions and 38 deletions

View File

@ -51,7 +51,7 @@ add_library(skyline SHARED
${source_DIR}/skyline/kernel/types/KPrivateMemory.cpp ${source_DIR}/skyline/kernel/types/KPrivateMemory.cpp
${source_DIR}/skyline/services/serviceman.cpp ${source_DIR}/skyline/services/serviceman.cpp
${source_DIR}/skyline/services/sm/IUserInterface.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/audout/audout.cpp
${source_DIR}/skyline/services/audren/IAudioRendererManager.cpp ${source_DIR}/skyline/services/audren/IAudioRendererManager.cpp
${source_DIR}/skyline/services/audren/IAudioRenderer.cpp ${source_DIR}/skyline/services/audren/IAudioRenderer.cpp

View File

@ -19,7 +19,7 @@ namespace skyline::service {
*/ */
enum class Service { enum class Service {
sm_IUserInterface, sm_IUserInterface,
fatal_u, fatalsrv_IService,
settings_ISystemSettingsServer, settings_ISystemSettingsServer,
apm, apm,
apm_ISession, 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 * @brief A map from every service's name as a std::string to the corresponding serviceEnum
*/ */
const static std::unordered_map<std::string, Service> ServiceString{ const static std::unordered_map<std::string, Service> ServiceString{
{"fatal:u", Service::fatal_u}, {"fatal:u", Service::fatalsrv_IService},
{"set:sys", Service::settings_ISystemSettingsServer}, {"set:sys", Service::settings_ISystemSettingsServer},
{"apm", Service::apm}, {"apm", Service::apm},
{"appletOE", Service::am_appletOE}, {"appletOE", Service::am_appletOE},

View File

@ -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<u32 *>(request.cmdArg));
}
}

View File

@ -1,19 +0,0 @@
#pragma once
#include <services/base_service.h>
#include <services/serviceman.h>
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);
};
}

View File

@ -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<u32 *>(request.cmdArg));
}
}

View File

@ -0,0 +1,19 @@
#pragma once
#include <services/base_service.h>
#include <services/serviceman.h>
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);
};
}

View File

@ -6,7 +6,7 @@
#include "am/applet.h" #include "am/applet.h"
#include "am/appletController.h" #include "am/appletController.h"
#include "audout/audout.h" #include "audout/audout.h"
#include "fatal/fatal.h" #include "fatalsrv/IService.h"
#include "hid/IHidServer.h" #include "hid/IHidServer.h"
#include "timesrv/IStaticService.h" #include "timesrv/IStaticService.h"
#include "fssrv/IFileSystemProxy.h" #include "fssrv/IFileSystemProxy.h"
@ -26,8 +26,8 @@ namespace skyline::service {
case Service::sm_IUserInterface: case Service::sm_IUserInterface:
serviceObj = std::make_shared<sm::IUserInterface>(state, *this); serviceObj = std::make_shared<sm::IUserInterface>(state, *this);
break; break;
case Service::fatal_u: case Service::fatalsrv_IService:
serviceObj = std::make_shared<fatal::fatalU>(state, *this); serviceObj = std::make_shared<fatalsrv::IService>(state, *this);
break; break;
case Service::settings_ISystemSettingsServer: case Service::settings_ISystemSettingsServer:
serviceObj = std::make_shared<settings::ISystemSettingsServer>(state, *this); serviceObj = std::make_shared<settings::ISystemSettingsServer>(state, *this);