mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-28 23:05:29 +03:00
Refactor service manager services
Use the new service naming convention. Fix some small code style issues with {} on if statements
This commit is contained in:
parent
ab33f692c6
commit
c8846ca07b
@ -50,7 +50,7 @@ add_library(skyline SHARED
|
||||
${source_DIR}/skyline/kernel/types/KTransferMemory.cpp
|
||||
${source_DIR}/skyline/kernel/types/KPrivateMemory.cpp
|
||||
${source_DIR}/skyline/services/serviceman.cpp
|
||||
${source_DIR}/skyline/services/sm/sm.cpp
|
||||
${source_DIR}/skyline/services/sm/IUserInterface.cpp
|
||||
${source_DIR}/skyline/services/fatal/fatal.cpp
|
||||
${source_DIR}/skyline/services/audout/audout.cpp
|
||||
${source_DIR}/skyline/services/audren/IAudioRendererManager.cpp
|
||||
|
@ -500,7 +500,7 @@ namespace skyline::kernel::svc {
|
||||
state.process->ReadMemory(port, state.ctx->registers.x1, constant::PortSize);
|
||||
handle_t handle{};
|
||||
if (std::strcmp(port, "sm:") == 0) {
|
||||
handle = state.os->serviceManager.NewSession(service::Service::sm);
|
||||
handle = state.os->serviceManager.NewSession(service::Service::sm_IUserInterface);
|
||||
} else {
|
||||
state.logger->Warn("svcConnectToNamedPort: Connecting to invalid port: '{}'", port);
|
||||
state.ctx->registers.w0 = constant::status::NotFound;
|
||||
|
@ -18,7 +18,7 @@ namespace skyline::service {
|
||||
* @brief This contains an enum for every service that's present
|
||||
*/
|
||||
enum class Service {
|
||||
sm,
|
||||
sm_IUserInterface,
|
||||
fatal_u,
|
||||
set_sys,
|
||||
apm,
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <kernel/types/KProcess.h>
|
||||
#include <services/audren/IAudioRendererManager.h>
|
||||
#include "sm/sm.h"
|
||||
#include "sm/IUserInterface.h"
|
||||
#include "set/sys.h"
|
||||
#include "apm/apm.h"
|
||||
#include "am/applet.h"
|
||||
@ -23,8 +23,8 @@ namespace skyline::service {
|
||||
|
||||
std::shared_ptr<BaseService> serviceObj;
|
||||
switch (serviceType) {
|
||||
case Service::sm:
|
||||
serviceObj = std::make_shared<sm::sm>(state, *this);
|
||||
case Service::sm_IUserInterface:
|
||||
serviceObj = std::make_shared<sm::IUserInterface>(state, *this);
|
||||
break;
|
||||
case Service::fatal_u:
|
||||
serviceObj = std::make_shared<fatal::fatalU>(state, *this);
|
||||
|
24
app/src/main/cpp/skyline/services/sm/IUserInterface.cpp
Normal file
24
app/src/main/cpp/skyline/services/sm/IUserInterface.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include "IUserInterface.h"
|
||||
|
||||
namespace skyline::service::sm {
|
||||
IUserInterface::IUserInterface(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::sm_IUserInterface, "IUserInterface:IUserInterface", {
|
||||
{0x0, SFUNC(IUserInterface::Initialize)},
|
||||
{0x1, SFUNC(IUserInterface::GetService)}
|
||||
}) {}
|
||||
|
||||
void IUserInterface::Initialize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {}
|
||||
|
||||
void IUserInterface::GetService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||
std::string serviceName(reinterpret_cast<char *>(request.cmdArg));
|
||||
if (serviceName.empty()) {
|
||||
response.errorCode = constant::status::ServiceInvName;
|
||||
} else {
|
||||
try {
|
||||
manager.NewService(serviceName, session, response);
|
||||
} catch (std::out_of_range &) {
|
||||
response.errorCode = constant::status::ServiceNotReg;
|
||||
state.logger->Warn("Service has not been implemented: \"{}\"", serviceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -5,11 +5,11 @@
|
||||
|
||||
namespace skyline::service::sm {
|
||||
/**
|
||||
* @brief sm: or Service Manager is responsible for providing handles to services (https://switchbrew.org/wiki/Services_API)
|
||||
* @brief IUserInterface or sm: is responsible for providing handles to services (https://switchbrew.org/wiki/Services_API)
|
||||
*/
|
||||
class sm : public BaseService {
|
||||
class IUserInterface : public BaseService {
|
||||
public:
|
||||
sm(const DeviceState &state, ServiceManager &manager);
|
||||
IUserInterface(const DeviceState &state, ServiceManager &manager);
|
||||
|
||||
/**
|
||||
* @brief This initializes the sm: service. It doesn't actually do anything. (https://switchbrew.org/wiki/Services_API#Initialize)
|
@ -1,24 +0,0 @@
|
||||
#include "sm.h"
|
||||
|
||||
namespace skyline::service::sm {
|
||||
sm::sm(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::sm, "sm", {
|
||||
{0x0, SFUNC(sm::Initialize)},
|
||||
{0x1, SFUNC(sm::GetService)}
|
||||
}) {}
|
||||
|
||||
void sm::Initialize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {}
|
||||
|
||||
void sm::GetService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||
std::string serviceName(reinterpret_cast<char *>(request.cmdArg));
|
||||
if (serviceName.empty())
|
||||
response.errorCode = constant::status::ServiceInvName;
|
||||
else {
|
||||
try {
|
||||
manager.NewService(serviceName, session, response);
|
||||
} catch (std::out_of_range &) {
|
||||
response.errorCode = constant::status::ServiceNotReg;
|
||||
state.logger->Warn("Service has not been implemented: \"{}\"", serviceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user