mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-26 05:34:16 +01:00
Refactor base service implementation
Remove looping support - it is slow and no services use it. Store service name in in base service class - removes the need for having sub-services in the service name map. General code clean up - remove {} from single if statements etc.
This commit is contained in:
parent
bbe61e37f2
commit
704a5bdcb1
@ -76,7 +76,6 @@ namespace skyline {
|
|||||||
std::lock_guard guard(jniMtx);
|
std::lock_guard guard(jniMtx);
|
||||||
if (Halt)
|
if (Halt)
|
||||||
break;
|
break;
|
||||||
state.os->serviceManager.Loop();
|
|
||||||
state.gpu->Loop();
|
state.gpu->Loop();
|
||||||
}
|
}
|
||||||
if (!Halt) {
|
if (!Halt) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "appletController.h"
|
#include "appletController.h"
|
||||||
|
|
||||||
namespace skyline::service::am {
|
namespace skyline::service::am {
|
||||||
appletOE::appletOE(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::am_appletOE, {
|
appletOE::appletOE(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_appletOE, "am:appletOE", {
|
||||||
{0x0, SFUNC(appletOE::OpenApplicationProxy)}
|
{0x0, SFUNC(appletOE::OpenApplicationProxy)}
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ namespace skyline::service::am {
|
|||||||
manager.RegisterService(SRVREG(IApplicationProxy), session, response);
|
manager.RegisterService(SRVREG(IApplicationProxy), session, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
appletAE::appletAE(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::am_appletAE, {
|
appletAE::appletAE(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_appletAE, "am:appletAE", {
|
||||||
{0x64, SFUNC(appletAE::OpenSystemAppletProxy)},
|
{0x64, SFUNC(appletAE::OpenSystemAppletProxy)},
|
||||||
{0xC8, SFUNC(appletAE::OpenLibraryAppletProxy)},
|
{0xC8, SFUNC(appletAE::OpenLibraryAppletProxy)},
|
||||||
{0xC9, SFUNC(appletAE::OpenLibraryAppletProxy)},
|
{0xC9, SFUNC(appletAE::OpenLibraryAppletProxy)},
|
||||||
@ -34,7 +34,7 @@ namespace skyline::service::am {
|
|||||||
manager.RegisterService(SRVREG(ISystemAppletProxy), session, response);
|
manager.RegisterService(SRVREG(ISystemAppletProxy), session, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseProxy::BaseProxy(const DeviceState &state, ServiceManager &manager, Service serviceType, const std::unordered_map<u32, std::function<void(type::KSession &, ipc::IpcRequest &, ipc::IpcResponse &)>> &vTable) : BaseService(state, manager, false, serviceType, vTable) {}
|
BaseProxy::BaseProxy(const DeviceState &state, ServiceManager &manager, const Service serviceType, const std::string &serviceName, const std::unordered_map<u32, std::function<void(type::KSession &, ipc::IpcRequest &, ipc::IpcResponse &)>> &vTable) : BaseService(state, manager, serviceType, serviceName, vTable) {}
|
||||||
|
|
||||||
void BaseProxy::GetCommonStateGetter(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
void BaseProxy::GetCommonStateGetter(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
manager.RegisterService(SRVREG(ICommonStateGetter), session, response);
|
manager.RegisterService(SRVREG(ICommonStateGetter), session, response);
|
||||||
@ -68,7 +68,7 @@ namespace skyline::service::am {
|
|||||||
manager.RegisterService(SRVREG(IAppletCommonFunctions), session, response);
|
manager.RegisterService(SRVREG(IAppletCommonFunctions), session, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
IApplicationProxy::IApplicationProxy(const DeviceState &state, ServiceManager &manager) : BaseProxy(state, manager, Service::am_IApplicationProxy, {
|
IApplicationProxy::IApplicationProxy(const DeviceState &state, ServiceManager &manager) : BaseProxy(state, manager, Service::am_IApplicationProxy, "am:IApplicationProxy", {
|
||||||
{0x0, SFUNC(BaseProxy::GetCommonStateGetter)},
|
{0x0, SFUNC(BaseProxy::GetCommonStateGetter)},
|
||||||
{0x1, SFUNC(BaseProxy::GetSelfController)},
|
{0x1, SFUNC(BaseProxy::GetSelfController)},
|
||||||
{0x2, SFUNC(BaseProxy::GetWindowController)},
|
{0x2, SFUNC(BaseProxy::GetWindowController)},
|
||||||
@ -83,7 +83,7 @@ namespace skyline::service::am {
|
|||||||
manager.RegisterService(SRVREG(IApplicationFunctions), session, response);
|
manager.RegisterService(SRVREG(IApplicationFunctions), session, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
ILibraryAppletProxy::ILibraryAppletProxy(const DeviceState &state, ServiceManager &manager) : BaseProxy(state, manager, Service::am_ILibraryAppletProxy, {
|
ILibraryAppletProxy::ILibraryAppletProxy(const DeviceState &state, ServiceManager &manager) : BaseProxy(state, manager, Service::am_ILibraryAppletProxy, "am:ILibraryAppletProxy", {
|
||||||
{0x0, SFUNC(BaseProxy::GetCommonStateGetter)},
|
{0x0, SFUNC(BaseProxy::GetCommonStateGetter)},
|
||||||
{0x1, SFUNC(BaseProxy::GetSelfController)},
|
{0x1, SFUNC(BaseProxy::GetSelfController)},
|
||||||
{0x2, SFUNC(BaseProxy::GetWindowController)},
|
{0x2, SFUNC(BaseProxy::GetWindowController)},
|
||||||
@ -93,7 +93,7 @@ namespace skyline::service::am {
|
|||||||
{0x3E8, SFUNC(BaseProxy::GetDebugFunctions)}
|
{0x3E8, SFUNC(BaseProxy::GetDebugFunctions)}
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
ISystemAppletProxy::ISystemAppletProxy(const DeviceState &state, ServiceManager &manager) : BaseProxy(state, manager, Service::am_ISystemAppletProxy, {
|
ISystemAppletProxy::ISystemAppletProxy(const DeviceState &state, ServiceManager &manager) : BaseProxy(state, manager, Service::am_ISystemAppletProxy, "am:ISystemAppletProxy", {
|
||||||
{0x0, SFUNC(BaseProxy::GetCommonStateGetter)},
|
{0x0, SFUNC(BaseProxy::GetCommonStateGetter)},
|
||||||
{0x1, SFUNC(BaseProxy::GetSelfController)},
|
{0x1, SFUNC(BaseProxy::GetSelfController)},
|
||||||
{0x2, SFUNC(BaseProxy::GetWindowController)},
|
{0x2, SFUNC(BaseProxy::GetWindowController)},
|
||||||
@ -104,7 +104,7 @@ namespace skyline::service::am {
|
|||||||
{0x3E8, SFUNC(BaseProxy::GetDebugFunctions)}
|
{0x3E8, SFUNC(BaseProxy::GetDebugFunctions)}
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
IOverlayAppletProxy::IOverlayAppletProxy(const DeviceState &state, ServiceManager &manager) : BaseProxy(state, manager, Service::am_IOverlayAppletProxy, {
|
IOverlayAppletProxy::IOverlayAppletProxy(const DeviceState &state, ServiceManager &manager) : BaseProxy(state, manager, Service::am_IOverlayAppletProxy, "am:IOverlayAppletProxy", {
|
||||||
{0x0, SFUNC(BaseProxy::GetCommonStateGetter)},
|
{0x0, SFUNC(BaseProxy::GetCommonStateGetter)},
|
||||||
{0x1, SFUNC(BaseProxy::GetSelfController)},
|
{0x1, SFUNC(BaseProxy::GetSelfController)},
|
||||||
{0x2, SFUNC(BaseProxy::GetWindowController)},
|
{0x2, SFUNC(BaseProxy::GetWindowController)},
|
||||||
|
@ -50,7 +50,7 @@ namespace skyline::service::am {
|
|||||||
*/
|
*/
|
||||||
class BaseProxy : public BaseService {
|
class BaseProxy : public BaseService {
|
||||||
public:
|
public:
|
||||||
BaseProxy(const DeviceState &state, ServiceManager &manager, Service serviceType, const std::unordered_map<u32, std::function<void(type::KSession &, ipc::IpcRequest &, ipc::IpcResponse &)>> &vTable);
|
BaseProxy(const DeviceState &state, ServiceManager &manager, const Service serviceType, const std::string &serviceName, const std::unordered_map<u32, std::function<void(type::KSession &, ipc::IpcRequest &, ipc::IpcResponse &)>> &vTable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This returns #ICommonStateGetter (https://switchbrew.org/wiki/Applet_Manager_services#ICommonStateGetter)
|
* @brief This returns #ICommonStateGetter (https://switchbrew.org/wiki/Applet_Manager_services#ICommonStateGetter)
|
||||||
|
@ -6,7 +6,7 @@ namespace skyline::service::am {
|
|||||||
messageEvent->Signal();
|
messageEvent->Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
ICommonStateGetter::ICommonStateGetter(const DeviceState &state, ServiceManager &manager) : messageEvent(std::make_shared<type::KEvent>(state)), BaseService(state, manager, false, Service::am_ICommonStateGetter, {
|
ICommonStateGetter::ICommonStateGetter(const DeviceState &state, ServiceManager &manager) : messageEvent(std::make_shared<type::KEvent>(state)), BaseService(state, manager, Service::am_ICommonStateGetter, "am:ICommonStateGetter", {
|
||||||
{0x0, SFUNC(ICommonStateGetter::GetEventHandle)},
|
{0x0, SFUNC(ICommonStateGetter::GetEventHandle)},
|
||||||
{0x1, SFUNC(ICommonStateGetter::ReceiveMessage)},
|
{0x1, SFUNC(ICommonStateGetter::ReceiveMessage)},
|
||||||
{0x5, SFUNC(ICommonStateGetter::GetOperationMode)},
|
{0x5, SFUNC(ICommonStateGetter::GetOperationMode)},
|
||||||
@ -56,7 +56,7 @@ namespace skyline::service::am {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ISelfController::ISelfController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::am_ISelfController, {
|
ISelfController::ISelfController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_ISelfController, "am:ISelfController", {
|
||||||
{0xB, SFUNC(ISelfController::SetOperationModeChangedNotification)},
|
{0xB, SFUNC(ISelfController::SetOperationModeChangedNotification)},
|
||||||
{0xC, SFUNC(ISelfController::SetPerformanceModeChangedNotification)},
|
{0xC, SFUNC(ISelfController::SetPerformanceModeChangedNotification)},
|
||||||
{0xD, SFUNC(ISelfController::SetFocusHandlingMode)},
|
{0xD, SFUNC(ISelfController::SetFocusHandlingMode)},
|
||||||
@ -80,7 +80,7 @@ namespace skyline::service::am {
|
|||||||
response.Push<u64>(0);
|
response.Push<u64>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
IWindowController::IWindowController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::am_IWindowController, {
|
IWindowController::IWindowController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IWindowController, "am:IWindowController", {
|
||||||
{0x1, SFUNC(IWindowController::GetAppletResourceUserId)},
|
{0x1, SFUNC(IWindowController::GetAppletResourceUserId)},
|
||||||
{0xA, SFUNC(IWindowController::AcquireForegroundRights)}
|
{0xA, SFUNC(IWindowController::AcquireForegroundRights)}
|
||||||
}) {}
|
}) {}
|
||||||
@ -91,16 +91,16 @@ namespace skyline::service::am {
|
|||||||
|
|
||||||
void IWindowController::AcquireForegroundRights(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {}
|
void IWindowController::AcquireForegroundRights(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {}
|
||||||
|
|
||||||
IAudioController::IAudioController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::am_IAudioController, {
|
IAudioController::IAudioController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IAudioController, "am:IAudioController", {
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
IDisplayController::IDisplayController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::am_IDisplayController, {
|
IDisplayController::IDisplayController(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IDisplayController, "am:IDisplayController", {
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
ILibraryAppletCreator::ILibraryAppletCreator(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::am_ILibraryAppletCreator, {
|
ILibraryAppletCreator::ILibraryAppletCreator(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_ILibraryAppletCreator, "am:ILibraryAppletCreator", {
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
IApplicationFunctions::IApplicationFunctions(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::am_IApplicationFunctions, {
|
IApplicationFunctions::IApplicationFunctions(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IApplicationFunctions, "am:IApplicationFunctions", {
|
||||||
{0x28, SFUNC(IApplicationFunctions::NotifyRunning)}
|
{0x28, SFUNC(IApplicationFunctions::NotifyRunning)}
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
@ -108,9 +108,9 @@ namespace skyline::service::am {
|
|||||||
response.Push<u8>(1);
|
response.Push<u8>(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
IDebugFunctions::IDebugFunctions(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::am_IDebugFunctions, {
|
IDebugFunctions::IDebugFunctions(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IDebugFunctions, "am:IDebugFunctions", {
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
IAppletCommonFunctions::IAppletCommonFunctions(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::am_IAppletCommonFunctions, {
|
IAppletCommonFunctions::IAppletCommonFunctions(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::am_IAppletCommonFunctions, "am:IAppletCommonFunctions", {
|
||||||
}) {}
|
}) {}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "apm.h"
|
#include "apm.h"
|
||||||
|
|
||||||
namespace skyline::service::apm {
|
namespace skyline::service::apm {
|
||||||
apm::apm(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::apm, {
|
apm::apm(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::apm, "apm", {
|
||||||
{0x0, SFUNC(apm::OpenSession)}
|
{0x0, SFUNC(apm::OpenSession)}
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
@ -9,7 +9,7 @@ namespace skyline::service::apm {
|
|||||||
manager.RegisterService(std::make_shared<ISession>(state, manager), session, response);
|
manager.RegisterService(std::make_shared<ISession>(state, manager), session, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
ISession::ISession(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::apm_ISession, {
|
ISession::ISession(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::apm_ISession, "apm:ISession", {
|
||||||
{0x0, SFUNC(ISession::SetPerformanceConfiguration)},
|
{0x0, SFUNC(ISession::SetPerformanceConfiguration)},
|
||||||
{0x1, SFUNC(ISession::GetPerformanceConfiguration)}
|
{0x1, SFUNC(ISession::GetPerformanceConfiguration)}
|
||||||
}) {}
|
}) {}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <kernel/types/KProcess.h>
|
#include <kernel/types/KProcess.h>
|
||||||
|
|
||||||
namespace skyline::service::audout {
|
namespace skyline::service::audout {
|
||||||
audoutU::audoutU(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::audout_u, {
|
audoutU::audoutU(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::audout_u, "audout:u", {
|
||||||
{0x0, SFUNC(audoutU::ListAudioOuts)},
|
{0x0, SFUNC(audoutU::ListAudioOuts)},
|
||||||
{0x1, SFUNC(audoutU::OpenAudioOut)}
|
{0x1, SFUNC(audoutU::OpenAudioOut)}
|
||||||
}) {}
|
}) {}
|
||||||
@ -30,7 +30,7 @@ namespace skyline::service::audout {
|
|||||||
response.Push(static_cast<u32>(audio::AudioOutState::Stopped));
|
response.Push(static_cast<u32>(audio::AudioOutState::Stopped));
|
||||||
}
|
}
|
||||||
|
|
||||||
IAudioOut::IAudioOut(const DeviceState &state, ServiceManager &manager, int channelCount, int sampleRate) : sampleRate(sampleRate), channelCount(channelCount), releaseEvent(std::make_shared<type::KEvent>(state)), BaseService(state, manager, false, Service::audout_IAudioOut, {
|
IAudioOut::IAudioOut(const DeviceState &state, ServiceManager &manager, int channelCount, int sampleRate) : sampleRate(sampleRate), channelCount(channelCount), releaseEvent(std::make_shared<type::KEvent>(state)), BaseService(state, manager, Service::audout_IAudioOut, "audout:IAudioOut", {
|
||||||
{0x0, SFUNC(IAudioOut::GetAudioOutState)},
|
{0x0, SFUNC(IAudioOut::GetAudioOutState)},
|
||||||
{0x1, SFUNC(IAudioOut::StartAudioOut)},
|
{0x1, SFUNC(IAudioOut::StartAudioOut)},
|
||||||
{0x2, SFUNC(IAudioOut::StopAudioOut)},
|
{0x2, SFUNC(IAudioOut::StopAudioOut)},
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <kernel/types/KProcess.h>
|
#include <kernel/types/KProcess.h>
|
||||||
|
|
||||||
namespace skyline::service::audren {
|
namespace skyline::service::audren {
|
||||||
IAudioRenderer::IAudioRenderer(const DeviceState &state, ServiceManager &manager, AudioRendererParams ¶ms) : releaseEvent(std::make_shared<type::KEvent>(state)), rendererParams(params), BaseService(state, manager, false, Service::IAudioRenderer, {
|
IAudioRenderer::IAudioRenderer(const DeviceState &state, ServiceManager &manager, AudioRendererParams ¶ms) : releaseEvent(std::make_shared<type::KEvent>(state)), rendererParams(params), BaseService(state, manager, Service::IAudioRenderer, "IAudioRenderer", {
|
||||||
{0x0, SFUNC(IAudioRenderer::GetSampleRate)},
|
{0x0, SFUNC(IAudioRenderer::GetSampleRate)},
|
||||||
{0x1, SFUNC(IAudioRenderer::GetSampleCount)},
|
{0x1, SFUNC(IAudioRenderer::GetSampleCount)},
|
||||||
{0x2, SFUNC(IAudioRenderer::GetMixBufferCount)},
|
{0x2, SFUNC(IAudioRenderer::GetMixBufferCount)},
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <kernel/types/KProcess.h>
|
#include <kernel/types/KProcess.h>
|
||||||
|
|
||||||
namespace skyline::service::audren {
|
namespace skyline::service::audren {
|
||||||
IAudioRendererManager::IAudioRendererManager(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::IAudioRendererManager, {
|
IAudioRendererManager::IAudioRendererManager(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::IAudioRendererManager, "IAudioRendererManager", {
|
||||||
{0x0, SFUNC(IAudioRendererManager::OpenAudioRenderer)},
|
{0x0, SFUNC(IAudioRendererManager::OpenAudioRenderer)},
|
||||||
{0x1, SFUNC(IAudioRendererManager::GetAudioRendererWorkBufferSize)}
|
{0x1, SFUNC(IAudioRendererManager::GetAudioRendererWorkBufferSize)}
|
||||||
}) {}
|
}) {}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <common.h>
|
|
||||||
#include <kernel/ipc.h>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <kernel/ipc.h>
|
||||||
|
#include <common.h>
|
||||||
|
|
||||||
#define SFUNC(function) std::bind(&function, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)
|
#define SFUNC(function) std::bind(&function, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)
|
||||||
#define SRVREG(class) std::make_shared<class>(state, manager)
|
#define SRVREG(class) std::make_shared<class>(state, manager)
|
||||||
@ -10,8 +10,10 @@
|
|||||||
namespace skyline::kernel::type {
|
namespace skyline::kernel::type {
|
||||||
class KSession;
|
class KSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace skyline::service {
|
namespace skyline::service {
|
||||||
using namespace kernel;
|
using namespace kernel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This contains an enum for every service that's present
|
* @brief This contains an enum for every service that's present
|
||||||
*/
|
*/
|
||||||
@ -59,46 +61,22 @@ 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{
|
||||||
{"sm:", Service::sm},
|
|
||||||
{"fatal:u", Service::fatal_u},
|
{"fatal:u", Service::fatal_u},
|
||||||
{"set:sys", Service::set_sys},
|
{"set:sys", Service::set_sys},
|
||||||
{"apm", Service::apm},
|
{"apm", Service::apm},
|
||||||
{"apm:ISession", Service::apm_ISession},
|
|
||||||
{"appletOE", Service::am_appletOE},
|
{"appletOE", Service::am_appletOE},
|
||||||
{"appletAE", Service::am_appletAE},
|
{"appletAE", Service::am_appletAE},
|
||||||
{"am:IApplicationProxy", Service::am_IApplicationProxy},
|
|
||||||
{"am:ILibraryAppletProxy", Service::am_ILibraryAppletProxy},
|
|
||||||
{"am:ISystemAppletProxy", Service::am_ISystemAppletProxy},
|
|
||||||
{"am:IOverlayAppletProxy", Service::am_IOverlayAppletProxy},
|
|
||||||
{"am:ICommonStateGetter", Service::am_ICommonStateGetter},
|
|
||||||
{"am:ISelfController", Service::am_ISelfController},
|
|
||||||
{"am:IWindowController", Service::am_IWindowController},
|
|
||||||
{"am:IAudioController", Service::am_IAudioController},
|
|
||||||
{"am:IDisplayController", Service::am_IDisplayController},
|
|
||||||
{"am:ILibraryAppletCreator", Service::am_ILibraryAppletCreator},
|
|
||||||
{"am:IApplicationFunctions", Service::am_IApplicationFunctions},
|
|
||||||
{"am:IDebugFunctions", Service::am_IDebugFunctions},
|
|
||||||
{"am:IAppletCommonFunctions", Service::am_IAppletCommonFunctions},
|
|
||||||
{"audout:u", Service::audout_u},
|
{"audout:u", Service::audout_u},
|
||||||
{"audout:IAudioOut", Service::audout_IAudioOut},
|
|
||||||
{"audren:u", Service::IAudioRendererManager},
|
{"audren:u", Service::IAudioRendererManager},
|
||||||
{"hid", Service::hid},
|
{"hid", Service::hid},
|
||||||
{"hid:IAppletResource", Service::hid_IAppletResource},
|
|
||||||
{"time:s", Service::time},
|
{"time:s", Service::time},
|
||||||
{"time:a", Service::time},
|
{"time:a", Service::time},
|
||||||
{"time:ISystemClock", Service::time_ISystemClock},
|
|
||||||
{"time:ITimeZoneService", Service::time_ITimeZoneService},
|
|
||||||
{"fsp-srv", Service::fs_fsp},
|
{"fsp-srv", Service::fs_fsp},
|
||||||
{"fs:IFileSystem", Service::fs_IFileSystem},
|
|
||||||
{"nvdrv", Service::nvdrv},
|
{"nvdrv", Service::nvdrv},
|
||||||
{"nvdrv:a", Service::nvdrv},
|
{"nvdrv:a", Service::nvdrv},
|
||||||
{"nvdrv:s", Service::nvdrv},
|
{"nvdrv:s", Service::nvdrv},
|
||||||
{"nvdrv:t", Service::nvdrv},
|
{"nvdrv:t", Service::nvdrv},
|
||||||
{"vi:m", Service::vi_m},
|
{"vi:m", Service::vi_m},
|
||||||
{"vi:IApplicationDisplayService", Service::vi_IApplicationDisplayService},
|
|
||||||
{"vi:ISystemDisplayService", Service::vi_ISystemDisplayService},
|
|
||||||
{"vi:IManagerDisplayService", Service::vi_IManagerDisplayService},
|
|
||||||
{"nvnflinger:dispdrv", Service::nvnflinger_dispdrv},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ServiceManager;
|
class ServiceManager;
|
||||||
@ -110,11 +88,11 @@ namespace skyline::service {
|
|||||||
protected:
|
protected:
|
||||||
const DeviceState &state; //!< The state of the device
|
const DeviceState &state; //!< The state of the device
|
||||||
ServiceManager &manager; //!< A pointer to the service manager
|
ServiceManager &manager; //!< A pointer to the service manager
|
||||||
std::unordered_map<u32, std::function<void(type::KSession &, ipc::IpcRequest &, ipc::IpcResponse &)>> vTable; //!< This holds the mapping from an object's CmdId to the actual function
|
const std::unordered_map<u32, std::function<void(type::KSession &, ipc::IpcRequest &, ipc::IpcResponse &)>> vTable; //!< This holds the mapping from an object's CmdId to the actual function
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Service serviceType; //!< The type of the service this is
|
const Service serviceType; //!< The type of the service this is
|
||||||
const bool hasLoop; //<! If the service has a loop or not
|
const std::string serviceName; //!< The name of the service
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param state The state of the device
|
* @param state The state of the device
|
||||||
@ -123,20 +101,7 @@ namespace skyline::service {
|
|||||||
* @param serviceName The name of the service
|
* @param serviceName The name of the service
|
||||||
* @param vTable The functions of the service
|
* @param vTable The functions of the service
|
||||||
*/
|
*/
|
||||||
BaseService(const DeviceState &state, ServiceManager &manager, bool hasLoop, Service serviceType, const std::unordered_map<u32, std::function<void(type::KSession &, ipc::IpcRequest &, ipc::IpcResponse &)>> &vTable) : state(state), manager(manager), hasLoop(hasLoop), serviceType(serviceType), vTable(vTable) {}
|
BaseService(const DeviceState &state, ServiceManager &manager, const Service serviceType, const std::string &serviceName, const std::unordered_map<u32, std::function<void(type::KSession &, ipc::IpcRequest &, ipc::IpcResponse &)>> &vTable) : state(state), manager(manager), serviceType(serviceType), serviceName(serviceName), vTable(vTable) {}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This returns the name of the current service
|
|
||||||
* @note It may not return the exact name the service was initialized with if there are multiple entries in ServiceString
|
|
||||||
* @return The name of the service
|
|
||||||
*/
|
|
||||||
std::string getName() {
|
|
||||||
std::string serviceName;
|
|
||||||
for (const auto&[name, type] : ServiceString)
|
|
||||||
if (type == serviceType)
|
|
||||||
serviceName = name;
|
|
||||||
return serviceName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This handles all IPC commands with type request to a service
|
* @brief This handles all IPC commands with type request to a service
|
||||||
@ -148,19 +113,14 @@ namespace skyline::service {
|
|||||||
try {
|
try {
|
||||||
function = vTable.at(request.payload->value);
|
function = vTable.at(request.payload->value);
|
||||||
} catch (std::out_of_range &) {
|
} catch (std::out_of_range &) {
|
||||||
state.logger->Warn("Cannot find function in service '{0}' (Type: {1}): 0x{2:X} ({2})", getName(), serviceType, u32(request.payload->value));
|
state.logger->Warn("Cannot find function in service '{0}' (Type: {1}): 0x{2:X} ({2})", serviceName, serviceType, static_cast<u32>(request.payload->value));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
function(session, request, response);
|
function(session, request, response);
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
throw exception("{} (Service: {})", e.what(), getName());
|
throw exception("{} (Service: {})", e.what(), serviceName);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is used by some services when they need to run some code at regular intervals
|
|
||||||
*/
|
|
||||||
virtual void Loop() {};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "fatal.h"
|
#include "fatal.h"
|
||||||
|
|
||||||
namespace skyline::service::fatal {
|
namespace skyline::service::fatal {
|
||||||
fatalU::fatalU(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::fatal_u, {
|
fatalU::fatalU(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::fatal_u, "fatal:u", {
|
||||||
{0x0, SFUNC(fatalU::ThrowFatal)},
|
{0x0, SFUNC(fatalU::ThrowFatal)},
|
||||||
{0x1, SFUNC(fatalU::ThrowFatal)},
|
{0x1, SFUNC(fatalU::ThrowFatal)},
|
||||||
{0x2, SFUNC(fatalU::ThrowFatal)}
|
{0x2, SFUNC(fatalU::ThrowFatal)}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "fs.h"
|
#include "fs.h"
|
||||||
|
|
||||||
namespace skyline::service::fs {
|
namespace skyline::service::fs {
|
||||||
fsp::fsp(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::fs_fsp, {
|
fsp::fsp(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::fs_fsp, "fs:fsp", {
|
||||||
{0x1, SFUNC(fsp::SetCurrentProcess)},
|
{0x1, SFUNC(fsp::SetCurrentProcess)},
|
||||||
{0x12, SFUNC(fsp::OpenSdCardFileSystem)}
|
{0x12, SFUNC(fsp::OpenSdCardFileSystem)}
|
||||||
}) {}
|
}) {}
|
||||||
@ -14,5 +14,5 @@ namespace skyline::service::fs {
|
|||||||
manager.RegisterService(std::make_shared<IFileSystem>(FsType::SdCard, state, manager), session, response);
|
manager.RegisterService(std::make_shared<IFileSystem>(FsType::SdCard, state, manager), session, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
IFileSystem::IFileSystem(FsType type, const DeviceState &state, ServiceManager &manager) : type(type), BaseService(state, manager, false, Service::fs_IFileSystem, {}) {}
|
IFileSystem::IFileSystem(FsType type, const DeviceState &state, ServiceManager &manager) : type(type), BaseService(state, manager, Service::fs_IFileSystem, "fs:IFileSystem", {}) {}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <os.h>
|
#include <os.h>
|
||||||
|
|
||||||
namespace skyline::service::hid {
|
namespace skyline::service::hid {
|
||||||
IAppletResource::IAppletResource(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::hid_IAppletResource, {
|
IAppletResource::IAppletResource(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::hid_IAppletResource, "hid:IAppletResource", {
|
||||||
{0x0, SFUNC(IAppletResource::GetSharedMemoryHandle)}
|
{0x0, SFUNC(IAppletResource::GetSharedMemoryHandle)}
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ namespace skyline::service::hid {
|
|||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
hid::hid(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::hid, {
|
hid::hid(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::hid, "hid", {
|
||||||
{0x0, SFUNC(hid::CreateAppletResource)},
|
{0x0, SFUNC(hid::CreateAppletResource)},
|
||||||
{0x64, SFUNC(hid::SetSupportedNpadStyleSet)},
|
{0x64, SFUNC(hid::SetSupportedNpadStyleSet)},
|
||||||
{0x66, SFUNC(hid::SetSupportedNpadIdType)},
|
{0x66, SFUNC(hid::SetSupportedNpadIdType)},
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <kernel/types/KProcess.h>
|
#include <kernel/types/KProcess.h>
|
||||||
|
|
||||||
namespace skyline::service::nvdrv {
|
namespace skyline::service::nvdrv {
|
||||||
nvdrv::nvdrv(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::nvdrv, {
|
nvdrv::nvdrv(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::nvdrv, "nvdrv", {
|
||||||
{0x0, SFUNC(nvdrv::Open)},
|
{0x0, SFUNC(nvdrv::Open)},
|
||||||
{0x1, SFUNC(nvdrv::Ioctl)},
|
{0x1, SFUNC(nvdrv::Ioctl)},
|
||||||
{0x2, SFUNC(nvdrv::Close)},
|
{0x2, SFUNC(nvdrv::Close)},
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <gpu.h>
|
#include <gpu.h>
|
||||||
|
|
||||||
namespace skyline::service::nvnflinger {
|
namespace skyline::service::nvnflinger {
|
||||||
dispdrv::dispdrv(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::nvnflinger_dispdrv, {
|
dispdrv::dispdrv(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::nvnflinger_dispdrv, "nvnflinger_dispdrv", {
|
||||||
{0x0, SFUNC(dispdrv::TransactParcel)},
|
{0x0, SFUNC(dispdrv::TransactParcel)},
|
||||||
{0x1, SFUNC(dispdrv::AdjustRefcount)},
|
{0x1, SFUNC(dispdrv::AdjustRefcount)},
|
||||||
{0x2, SFUNC(dispdrv::GetNativeHandle)},
|
{0x2, SFUNC(dispdrv::GetNativeHandle)},
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#include "serviceman.h"
|
|
||||||
#include <kernel/types/KProcess.h>
|
#include <kernel/types/KProcess.h>
|
||||||
#include <services/audren/IAudioRendererManager.h>
|
#include <services/audren/IAudioRendererManager.h>
|
||||||
#include "sm/sm.h"
|
#include "sm/sm.h"
|
||||||
@ -13,15 +12,15 @@
|
|||||||
#include "fs/fs.h"
|
#include "fs/fs.h"
|
||||||
#include "nvdrv/nvdrv.h"
|
#include "nvdrv/nvdrv.h"
|
||||||
#include "vi/vi_m.h"
|
#include "vi/vi_m.h"
|
||||||
#include "nvnflinger/dispdrv.h"
|
#include "serviceman.h"
|
||||||
|
|
||||||
namespace skyline::service {
|
namespace skyline::service {
|
||||||
ServiceManager::ServiceManager(const DeviceState &state) : state(state) {}
|
ServiceManager::ServiceManager(const DeviceState &state) : state(state) {}
|
||||||
|
|
||||||
std::shared_ptr<BaseService> ServiceManager::GetService(const Service serviceType) {
|
std::shared_ptr<BaseService> ServiceManager::GetService(const Service serviceType) {
|
||||||
if (serviceMap.count(serviceType)) {
|
if (serviceMap.count(serviceType))
|
||||||
return serviceMap.at(serviceType);
|
return serviceMap.at(serviceType);
|
||||||
}
|
|
||||||
std::shared_ptr<BaseService> serviceObj;
|
std::shared_ptr<BaseService> serviceObj;
|
||||||
switch (serviceType) {
|
switch (serviceType) {
|
||||||
case Service::sm:
|
case Service::sm:
|
||||||
@ -36,54 +35,12 @@ namespace skyline::service {
|
|||||||
case Service::apm:
|
case Service::apm:
|
||||||
serviceObj = std::make_shared<apm::apm>(state, *this);
|
serviceObj = std::make_shared<apm::apm>(state, *this);
|
||||||
break;
|
break;
|
||||||
case Service::apm_ISession:
|
|
||||||
serviceObj = std::make_shared<apm::ISession>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::am_appletOE:
|
case Service::am_appletOE:
|
||||||
serviceObj = std::make_shared<am::appletOE>(state, *this);
|
serviceObj = std::make_shared<am::appletOE>(state, *this);
|
||||||
break;
|
break;
|
||||||
case Service::am_appletAE:
|
case Service::am_appletAE:
|
||||||
serviceObj = std::make_shared<am::appletAE>(state, *this);
|
serviceObj = std::make_shared<am::appletAE>(state, *this);
|
||||||
break;
|
break;
|
||||||
case Service::am_IApplicationProxy:
|
|
||||||
serviceObj = std::make_shared<am::IApplicationProxy>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::am_ILibraryAppletProxy:
|
|
||||||
serviceObj = std::make_shared<am::ILibraryAppletProxy>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::am_ISystemAppletProxy:
|
|
||||||
serviceObj = std::make_shared<am::ISystemAppletProxy>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::am_IOverlayAppletProxy:
|
|
||||||
serviceObj = std::make_shared<am::IOverlayAppletProxy>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::am_ICommonStateGetter:
|
|
||||||
serviceObj = std::make_shared<am::ICommonStateGetter>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::am_IWindowController:
|
|
||||||
serviceObj = std::make_shared<am::IWindowController>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::am_IAudioController:
|
|
||||||
serviceObj = std::make_shared<am::IAudioController>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::am_IDisplayController:
|
|
||||||
serviceObj = std::make_shared<am::IDisplayController>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::am_ISelfController:
|
|
||||||
serviceObj = std::make_shared<am::ISelfController>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::am_ILibraryAppletCreator:
|
|
||||||
serviceObj = std::make_shared<am::ILibraryAppletCreator>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::am_IApplicationFunctions:
|
|
||||||
serviceObj = std::make_shared<am::IApplicationFunctions>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::am_IDebugFunctions:
|
|
||||||
serviceObj = std::make_shared<am::IDebugFunctions>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::am_IAppletCommonFunctions:
|
|
||||||
serviceObj = std::make_shared<am::IAppletCommonFunctions>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::audout_u:
|
case Service::audout_u:
|
||||||
serviceObj = std::make_shared<audout::audoutU>(state, *this);
|
serviceObj = std::make_shared<audout::audoutU>(state, *this);
|
||||||
break;
|
break;
|
||||||
@ -93,9 +50,6 @@ namespace skyline::service {
|
|||||||
case Service::hid:
|
case Service::hid:
|
||||||
serviceObj = std::make_shared<hid::hid>(state, *this);
|
serviceObj = std::make_shared<hid::hid>(state, *this);
|
||||||
break;
|
break;
|
||||||
case Service::hid_IAppletResource:
|
|
||||||
serviceObj = std::make_shared<hid::IAppletResource>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::time:
|
case Service::time:
|
||||||
serviceObj = std::make_shared<time::time>(state, *this);
|
serviceObj = std::make_shared<time::time>(state, *this);
|
||||||
break;
|
break;
|
||||||
@ -108,18 +62,6 @@ namespace skyline::service {
|
|||||||
case Service::vi_m:
|
case Service::vi_m:
|
||||||
serviceObj = std::make_shared<vi::vi_m>(state, *this);
|
serviceObj = std::make_shared<vi::vi_m>(state, *this);
|
||||||
break;
|
break;
|
||||||
case Service::vi_IApplicationDisplayService:
|
|
||||||
serviceObj = std::make_shared<vi::IApplicationDisplayService>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::vi_ISystemDisplayService:
|
|
||||||
serviceObj = std::make_shared<vi::ISystemDisplayService>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::vi_IManagerDisplayService:
|
|
||||||
serviceObj = std::make_shared<vi::IManagerDisplayService>(state, *this);
|
|
||||||
break;
|
|
||||||
case Service::nvnflinger_dispdrv:
|
|
||||||
serviceObj = std::make_shared<nvnflinger::dispdrv>(state, *this);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw exception("GetService called on missing object, type: {}", serviceType);
|
throw exception("GetService called on missing object, type: {}", serviceType);
|
||||||
}
|
}
|
||||||
@ -159,7 +101,7 @@ namespace skyline::service {
|
|||||||
handle = state.process->NewHandle<type::KSession>(serviceObject).handle;
|
handle = state.process->NewHandle<type::KSession>(serviceObject).handle;
|
||||||
response.moveHandles.push_back(handle);
|
response.moveHandles.push_back(handle);
|
||||||
}
|
}
|
||||||
state.logger->Debug("Service has been registered: \"{}\" (0x{:X})", serviceObject->getName(), handle);
|
state.logger->Debug("Service has been registered: \"{}\" (0x{:X})", serviceObject->serviceName, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceManager::CloseSession(const handle_t handle) {
|
void ServiceManager::CloseSession(const handle_t handle) {
|
||||||
@ -169,19 +111,13 @@ namespace skyline::service {
|
|||||||
if (session->isDomain) {
|
if (session->isDomain) {
|
||||||
for (const auto &[objectId, service] : session->domainTable)
|
for (const auto &[objectId, service] : session->domainTable)
|
||||||
serviceMap.erase(service->serviceType);
|
serviceMap.erase(service->serviceType);
|
||||||
} else
|
} else {
|
||||||
serviceMap.erase(session->serviceObject->serviceType);
|
serviceMap.erase(session->serviceObject->serviceType);
|
||||||
|
}
|
||||||
session->serviceStatus = type::KSession::ServiceStatus::Closed;
|
session->serviceStatus = type::KSession::ServiceStatus::Closed;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void ServiceManager::Loop() {
|
|
||||||
std::lock_guard serviceGuard(mutex);
|
|
||||||
for (auto&[type, service] : serviceMap)
|
|
||||||
if (service->hasLoop)
|
|
||||||
service->Loop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServiceManager::SyncRequestHandler(const handle_t handle) {
|
void ServiceManager::SyncRequestHandler(const handle_t handle) {
|
||||||
auto session = state.process->GetHandle<type::KSession>(handle);
|
auto session = state.process->GetHandle<type::KSession>(handle);
|
||||||
state.logger->Debug("----Start----");
|
state.logger->Debug("----Start----");
|
||||||
@ -191,7 +127,7 @@ namespace skyline::service {
|
|||||||
ipc::IpcRequest request(session->isDomain, state);
|
ipc::IpcRequest request(session->isDomain, state);
|
||||||
ipc::IpcResponse response(session->isDomain, state);
|
ipc::IpcResponse response(session->isDomain, state);
|
||||||
|
|
||||||
switch (static_cast<ipc::CommandType>(request.header->type)) {
|
switch (request.header->type) {
|
||||||
case ipc::CommandType::Request:
|
case ipc::CommandType::Request:
|
||||||
case ipc::CommandType::RequestWithContext:
|
case ipc::CommandType::RequestWithContext:
|
||||||
if (session->isDomain) {
|
if (session->isDomain) {
|
||||||
@ -209,12 +145,12 @@ namespace skyline::service {
|
|||||||
} catch (std::out_of_range &) {
|
} catch (std::out_of_range &) {
|
||||||
throw exception("Invalid object ID was used with domain request");
|
throw exception("Invalid object ID was used with domain request");
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
session->serviceObject->HandleRequest(*session, request, response);
|
session->serviceObject->HandleRequest(*session, request, response);
|
||||||
|
}
|
||||||
if (!response.nWrite)
|
if (!response.nWrite)
|
||||||
response.WriteResponse();
|
response.WriteResponse();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ipc::CommandType::Control:
|
case ipc::CommandType::Control:
|
||||||
case ipc::CommandType::ControlWithContext:
|
case ipc::CommandType::ControlWithContext:
|
||||||
state.logger->Debug("Control IPC Message: 0x{:X}", request.payload->value);
|
state.logger->Debug("Control IPC Message: 0x{:X}", request.payload->value);
|
||||||
@ -234,17 +170,16 @@ namespace skyline::service {
|
|||||||
}
|
}
|
||||||
response.WriteResponse();
|
response.WriteResponse();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ipc::CommandType::Close:
|
case ipc::CommandType::Close:
|
||||||
state.logger->Debug("Closing Session");
|
state.logger->Debug("Closing Session");
|
||||||
CloseSession(handle);
|
CloseSession(handle);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw exception("Unimplemented IPC message type: {}", u16(request.header->type));
|
throw exception("Unimplemented IPC message type: {}", static_cast<u16>(request.header->type));
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
state.logger->Warn("svcSendSyncRequest called on closed handle: 0x{:X}", handle);
|
state.logger->Warn("svcSendSyncRequest called on closed handle: 0x{:X}", handle);
|
||||||
|
}
|
||||||
state.logger->Debug("====End====");
|
state.logger->Debug("====End====");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <nce.h>
|
|
||||||
#include <kernel/types/KSession.h>
|
#include <kernel/types/KSession.h>
|
||||||
|
#include <nce.h>
|
||||||
#include "base_service.h"
|
#include "base_service.h"
|
||||||
|
|
||||||
namespace skyline::service {
|
namespace skyline::service {
|
||||||
@ -55,11 +55,6 @@ namespace skyline::service {
|
|||||||
*/
|
*/
|
||||||
void CloseSession(const handle_t handle);
|
void CloseSession(const handle_t handle);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is a function where the Services get to run their core event loops
|
|
||||||
*/
|
|
||||||
void Loop();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handles a Synchronous IPC Request
|
* @brief Handles a Synchronous IPC Request
|
||||||
* @param handle The handle of the object
|
* @param handle The handle of the object
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
#include <kernel/types/KProcess.h>
|
#include <kernel/types/KProcess.h>
|
||||||
|
|
||||||
namespace skyline::service::set {
|
namespace skyline::service::set {
|
||||||
sys::sys(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::set_sys, {{0x3, SFUNC(sys::GetFirmwareVersion)}}) {}
|
sys::sys(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::set_sys, "set:sys", {
|
||||||
|
{0x3, SFUNC(sys::GetFirmwareVersion)}}) {}
|
||||||
|
|
||||||
void sys::GetFirmwareVersion(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
void sys::GetFirmwareVersion(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
SysVerTitle title{.minor=9, .major=0, .micro=0, .revMajor=4, .platform="NX", .verHash="4de65c071fd0869695b7629f75eb97b2551dbf2f", .dispVer="9.0.0", .dispTitle="NintendoSDK Firmware for NX 9.0.0-4.0"};
|
SysVerTitle title{.minor=9, .major=0, .micro=0, .revMajor=4, .platform="NX", .verHash="4de65c071fd0869695b7629f75eb97b2551dbf2f", .dispVer="9.0.0", .dispTitle="NintendoSDK Firmware for NX 9.0.0-4.0"};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "sm.h"
|
#include "sm.h"
|
||||||
|
|
||||||
namespace skyline::service::sm {
|
namespace skyline::service::sm {
|
||||||
sm::sm(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::sm, {
|
sm::sm(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::sm, "sm", {
|
||||||
{0x0, SFUNC(sm::Initialize)},
|
{0x0, SFUNC(sm::Initialize)},
|
||||||
{0x1, SFUNC(sm::GetService)}
|
{0x1, SFUNC(sm::GetService)}
|
||||||
}) {}
|
}) {}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "timesrv.h"
|
#include "timesrv.h"
|
||||||
|
|
||||||
namespace skyline::service::time {
|
namespace skyline::service::time {
|
||||||
time::time(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::time, {
|
time::time(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::time, "time", {
|
||||||
{0x0, SFUNC(time::GetStandardUserSystemClock)},
|
{0x0, SFUNC(time::GetStandardUserSystemClock)},
|
||||||
{0x1, SFUNC(time::GetStandardNetworkSystemClock)},
|
{0x1, SFUNC(time::GetStandardNetworkSystemClock)},
|
||||||
{0x3, SFUNC(time::GetTimeZoneService)},
|
{0x3, SFUNC(time::GetTimeZoneService)},
|
||||||
@ -24,7 +24,7 @@ namespace skyline::service::time {
|
|||||||
manager.RegisterService(std::make_shared<ISystemClock>(SystemClockType::Local, state, manager), session, response);
|
manager.RegisterService(std::make_shared<ISystemClock>(SystemClockType::Local, state, manager), session, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
ISystemClock::ISystemClock(SystemClockType clockType, const DeviceState &state, ServiceManager &manager) : type(clockType), BaseService(state, manager, false, Service::time_ISystemClock, {
|
ISystemClock::ISystemClock(SystemClockType clockType, const DeviceState &state, ServiceManager &manager) : type(clockType), BaseService(state, manager, Service::time_ISystemClock, "time:ISystemClock", {
|
||||||
{0x0, SFUNC(ISystemClock::GetCurrentTime)}
|
{0x0, SFUNC(ISystemClock::GetCurrentTime)}
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ namespace skyline::service::time {
|
|||||||
response.Push<u64>(static_cast<u64>(std::time(nullptr)));
|
response.Push<u64>(static_cast<u64>(std::time(nullptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ITimeZoneService::ITimeZoneService(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::time_ITimeZoneService, {
|
ITimeZoneService::ITimeZoneService(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::time_ITimeZoneService, "time:ITimeZoneService", {
|
||||||
{0x65, SFUNC(ITimeZoneService::ToCalendarTimeWithMyRule)}
|
{0x65, SFUNC(ITimeZoneService::ToCalendarTimeWithMyRule)}
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <gpu/display.h>
|
#include <gpu/display.h>
|
||||||
|
|
||||||
namespace skyline::service::vi {
|
namespace skyline::service::vi {
|
||||||
vi_m::vi_m(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, false, Service::nvdrv, {
|
vi_m::vi_m(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::nvdrv, "nvdrv", {
|
||||||
{0x2, SFUNC(vi_m::GetDisplayService)}
|
{0x2, SFUNC(vi_m::GetDisplayService)}
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ namespace skyline::service::vi {
|
|||||||
manager.RegisterService(SRVREG(IApplicationDisplayService), session, response);
|
manager.RegisterService(SRVREG(IApplicationDisplayService), session, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
IDisplayService::IDisplayService(const DeviceState &state, ServiceManager &manager, Service serviceType, const std::unordered_map<u32, std::function<void(type::KSession &, ipc::IpcRequest &, ipc::IpcResponse &)>> &vTable) : BaseService(state, manager, false, serviceType, vTable) {}
|
IDisplayService::IDisplayService(const DeviceState &state, ServiceManager &manager, const Service serviceType, const std::string &serviceName, const std::unordered_map<u32, std::function<void(type::KSession &, ipc::IpcRequest &, ipc::IpcResponse &)>> &vTable) : BaseService(state, manager, serviceType, serviceName, vTable) {}
|
||||||
|
|
||||||
void IDisplayService::CreateStrayLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
void IDisplayService::CreateStrayLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
state.logger->Debug("Creating Stray Layer");
|
state.logger->Debug("Creating Stray Layer");
|
||||||
@ -28,7 +28,7 @@ namespace skyline::service::vi {
|
|||||||
response.Push<u64>(parcel.WriteParcel(request.outputBuf.at(0)));
|
response.Push<u64>(parcel.WriteParcel(request.outputBuf.at(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
IApplicationDisplayService::IApplicationDisplayService(const DeviceState &state, ServiceManager &manager) : IDisplayService(state, manager, Service::vi_IApplicationDisplayService, {
|
IApplicationDisplayService::IApplicationDisplayService(const DeviceState &state, ServiceManager &manager) : IDisplayService(state, manager, Service::vi_IApplicationDisplayService, "vi:IApplicationDisplayService", {
|
||||||
{0x64, SFUNC(IApplicationDisplayService::GetRelayService)},
|
{0x64, SFUNC(IApplicationDisplayService::GetRelayService)},
|
||||||
{0x65, SFUNC(IApplicationDisplayService::GetSystemDisplayService)},
|
{0x65, SFUNC(IApplicationDisplayService::GetSystemDisplayService)},
|
||||||
{0x66, SFUNC(IApplicationDisplayService::GetManagerDisplayService)},
|
{0x66, SFUNC(IApplicationDisplayService::GetManagerDisplayService)},
|
||||||
@ -110,14 +110,14 @@ namespace skyline::service::vi {
|
|||||||
response.copyHandles.push_back(handle);
|
response.copyHandles.push_back(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
ISystemDisplayService::ISystemDisplayService(const DeviceState &state, ServiceManager &manager) : IDisplayService(state, manager, Service::vi_ISystemDisplayService, {
|
ISystemDisplayService::ISystemDisplayService(const DeviceState &state, ServiceManager &manager) : IDisplayService(state, manager, Service::vi_ISystemDisplayService, "vi:ISystemDisplayService", {
|
||||||
{0x89D, SFUNC(ISystemDisplayService::SetLayerZ)},
|
{0x89D, SFUNC(ISystemDisplayService::SetLayerZ)},
|
||||||
{0x908, SFUNC(IDisplayService::CreateStrayLayer)}
|
{0x908, SFUNC(IDisplayService::CreateStrayLayer)}
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
void ISystemDisplayService::SetLayerZ(skyline::kernel::type::KSession &session, skyline::kernel::ipc::IpcRequest &request, skyline::kernel::ipc::IpcResponse &response) {}
|
void ISystemDisplayService::SetLayerZ(skyline::kernel::type::KSession &session, skyline::kernel::ipc::IpcRequest &request, skyline::kernel::ipc::IpcResponse &response) {}
|
||||||
|
|
||||||
IManagerDisplayService::IManagerDisplayService(const DeviceState &state, ServiceManager &manager) : IDisplayService(state, manager, Service::vi_IManagerDisplayService, {
|
IManagerDisplayService::IManagerDisplayService(const DeviceState &state, ServiceManager &manager) : IDisplayService(state, manager, Service::vi_IManagerDisplayService, "vi:IManagerDisplayService", {
|
||||||
{0x7DA, SFUNC(IManagerDisplayService::CreateManagedLayer)},
|
{0x7DA, SFUNC(IManagerDisplayService::CreateManagedLayer)},
|
||||||
{0x7DB, SFUNC(IManagerDisplayService::DestroyManagedLayer)},
|
{0x7DB, SFUNC(IManagerDisplayService::DestroyManagedLayer)},
|
||||||
{0x7DC, SFUNC(IDisplayService::CreateStrayLayer)},
|
{0x7DC, SFUNC(IDisplayService::CreateStrayLayer)},
|
||||||
|
@ -38,7 +38,7 @@ namespace skyline::service::vi {
|
|||||||
static_assert(sizeof(LayerParcel) == 0x28);
|
static_assert(sizeof(LayerParcel) == 0x28);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IDisplayService(const DeviceState &state, ServiceManager &manager, Service serviceType, const std::unordered_map<u32, std::function<void(type::KSession &, ipc::IpcRequest &, ipc::IpcResponse &)>> &vTable);
|
IDisplayService(const DeviceState &state, ServiceManager &manager, const Service serviceType, const std::string &serviceName, const std::unordered_map<u32, std::function<void(type::KSession &, ipc::IpcRequest &, ipc::IpcResponse &)>> &vTable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This takes a display's ID and returns a layer ID and the corresponding buffer ID
|
* @brief This takes a display's ID and returns a layer ID and the corresponding buffer ID
|
||||||
|
Loading…
Reference in New Issue
Block a user