summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/core.cpp2
-rw-r--r--src/core/hle/service/sm/sm.cpp11
-rw-r--r--src/core/hle/service/sm/sm.h7
3 files changed, 11 insertions, 9 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 44aaba242..81e8cc338 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -178,7 +178,7 @@ struct System::Impl {
178 arp_manager.ResetAll(); 178 arp_manager.ResetAll();
179 179
180 telemetry_session = std::make_unique<Core::TelemetrySession>(); 180 telemetry_session = std::make_unique<Core::TelemetrySession>();
181 service_manager = std::make_shared<Service::SM::ServiceManager>(); 181 service_manager = std::make_shared<Service::SM::ServiceManager>(kernel);
182 182
183 Service::Init(service_manager, system); 183 Service::Init(service_manager, system);
184 GDBStub::DeferStart(); 184 GDBStub::DeferStart();
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp
index 586b3d8eb..9c1da361b 100644
--- a/src/core/hle/service/sm/sm.cpp
+++ b/src/core/hle/service/sm/sm.cpp
@@ -19,7 +19,7 @@ constexpr ResultCode ERR_ALREADY_REGISTERED(ErrorModule::SM, 4);
19constexpr ResultCode ERR_INVALID_NAME(ErrorModule::SM, 6); 19constexpr ResultCode ERR_INVALID_NAME(ErrorModule::SM, 6);
20constexpr ResultCode ERR_SERVICE_NOT_REGISTERED(ErrorModule::SM, 7); 20constexpr ResultCode ERR_SERVICE_NOT_REGISTERED(ErrorModule::SM, 7);
21 21
22ServiceManager::ServiceManager() = default; 22ServiceManager::ServiceManager(Kernel::KernelCore& kernel_) : kernel{kernel_} {}
23ServiceManager::~ServiceManager() = default; 23ServiceManager::~ServiceManager() = default;
24 24
25void ServiceManager::InvokeControlRequest(Kernel::HLERequestContext& context) { 25void ServiceManager::InvokeControlRequest(Kernel::HLERequestContext& context) {
@@ -27,11 +27,11 @@ void ServiceManager::InvokeControlRequest(Kernel::HLERequestContext& context) {
27} 27}
28 28
29static ResultCode ValidateServiceName(const std::string& name) { 29static ResultCode ValidateServiceName(const std::string& name) {
30 if (name.size() <= 0 || name.size() > 8) { 30 if (name.empty() || name.size() > 8) {
31 LOG_ERROR(Service_SM, "Invalid service name! service={}", name); 31 LOG_ERROR(Service_SM, "Invalid service name! service={}", name);
32 return ERR_INVALID_NAME; 32 return ERR_INVALID_NAME;
33 } 33 }
34 if (name.find('\0') != std::string::npos) { 34 if (name.rfind('\0') != std::string::npos) {
35 LOG_ERROR(Service_SM, "A non null terminated service was passed"); 35 LOG_ERROR(Service_SM, "A non null terminated service was passed");
36 return ERR_INVALID_NAME; 36 return ERR_INVALID_NAME;
37 } 37 }
@@ -48,8 +48,8 @@ void ServiceManager::InstallInterfaces(std::shared_ptr<ServiceManager> self,
48 self->controller_interface = std::make_unique<Controller>(); 48 self->controller_interface = std::make_unique<Controller>();
49} 49}
50 50
51ResultVal<std::shared_ptr<Kernel::ServerPort>> ServiceManager::RegisterService( 51ResultVal<std::shared_ptr<Kernel::ServerPort>> ServiceManager::RegisterService(std::string name,
52 std::string name, unsigned int max_sessions) { 52 u32 max_sessions) {
53 53
54 CASCADE_CODE(ValidateServiceName(name)); 54 CASCADE_CODE(ValidateServiceName(name));
55 55
@@ -58,7 +58,6 @@ ResultVal<std::shared_ptr<Kernel::ServerPort>> ServiceManager::RegisterService(
58 return ERR_ALREADY_REGISTERED; 58 return ERR_ALREADY_REGISTERED;
59 } 59 }
60 60
61 auto& kernel = Core::System::GetInstance().Kernel();
62 auto [server_port, client_port] = 61 auto [server_port, client_port] =
63 Kernel::ServerPort::CreatePortPair(kernel, max_sessions, name); 62 Kernel::ServerPort::CreatePortPair(kernel, max_sessions, name);
64 63
diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h
index aabf166b7..6790c86f0 100644
--- a/src/core/hle/service/sm/sm.h
+++ b/src/core/hle/service/sm/sm.h
@@ -48,11 +48,11 @@ class ServiceManager {
48public: 48public:
49 static void InstallInterfaces(std::shared_ptr<ServiceManager> self, Kernel::KernelCore& kernel); 49 static void InstallInterfaces(std::shared_ptr<ServiceManager> self, Kernel::KernelCore& kernel);
50 50
51 ServiceManager(); 51 explicit ServiceManager(Kernel::KernelCore& kernel_);
52 ~ServiceManager(); 52 ~ServiceManager();
53 53
54 ResultVal<std::shared_ptr<Kernel::ServerPort>> RegisterService(std::string name, 54 ResultVal<std::shared_ptr<Kernel::ServerPort>> RegisterService(std::string name,
55 unsigned int max_sessions); 55 u32 max_sessions);
56 ResultCode UnregisterService(const std::string& name); 56 ResultCode UnregisterService(const std::string& name);
57 ResultVal<std::shared_ptr<Kernel::ClientPort>> GetServicePort(const std::string& name); 57 ResultVal<std::shared_ptr<Kernel::ClientPort>> GetServicePort(const std::string& name);
58 ResultVal<std::shared_ptr<Kernel::ClientSession>> ConnectToService(const std::string& name); 58 ResultVal<std::shared_ptr<Kernel::ClientSession>> ConnectToService(const std::string& name);
@@ -79,6 +79,9 @@ private:
79 79
80 /// Map of registered services, retrieved using GetServicePort or ConnectToService. 80 /// Map of registered services, retrieved using GetServicePort or ConnectToService.
81 std::unordered_map<std::string, std::shared_ptr<Kernel::ClientPort>> registered_services; 81 std::unordered_map<std::string, std::shared_ptr<Kernel::ClientPort>> registered_services;
82
83 /// Kernel context
84 Kernel::KernelCore& kernel;
82}; 85};
83 86
84} // namespace Service::SM 87} // namespace Service::SM