2018-01-13 21:22:39 +00:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2017-06-06 06:31:59 +00:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include "core/hle/kernel/kernel.h"
|
|
|
|
#include "core/hle/result.h"
|
|
|
|
#include "core/hle/service/service.h"
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
class ClientPort;
|
|
|
|
class ClientSession;
|
|
|
|
class ServerPort;
|
|
|
|
class SessionRequestHandler;
|
|
|
|
} // namespace Kernel
|
|
|
|
|
2018-04-20 01:41:44 +00:00
|
|
|
namespace Service::SM {
|
2017-06-06 06:31:59 +00:00
|
|
|
|
2017-10-15 02:18:42 +00:00
|
|
|
/// Interface to "sm:" service
|
|
|
|
class SM final : public ServiceFramework<SM> {
|
|
|
|
public:
|
2017-12-28 20:27:30 +00:00
|
|
|
SM(std::shared_ptr<ServiceManager> service_manager);
|
|
|
|
~SM() = default;
|
2017-10-15 02:18:42 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void Initialize(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetService(Kernel::HLERequestContext& ctx);
|
|
|
|
|
|
|
|
std::shared_ptr<ServiceManager> service_manager;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Controller;
|
2017-06-07 04:25:28 +00:00
|
|
|
|
2017-10-31 23:26:11 +00:00
|
|
|
constexpr ResultCode ERR_SERVICE_NOT_REGISTERED(-1);
|
|
|
|
constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED(-1);
|
|
|
|
constexpr ResultCode ERR_INVALID_NAME_SIZE(-1);
|
|
|
|
constexpr ResultCode ERR_NAME_CONTAINS_NUL(-1);
|
|
|
|
constexpr ResultCode ERR_ALREADY_REGISTERED(-1);
|
2017-06-06 06:31:59 +00:00
|
|
|
|
|
|
|
class ServiceManager {
|
|
|
|
public:
|
2017-06-07 04:25:28 +00:00
|
|
|
static void InstallInterfaces(std::shared_ptr<ServiceManager> self);
|
|
|
|
|
2017-06-06 06:31:59 +00:00
|
|
|
ResultVal<Kernel::SharedPtr<Kernel::ServerPort>> RegisterService(std::string name,
|
|
|
|
unsigned int max_sessions);
|
|
|
|
ResultVal<Kernel::SharedPtr<Kernel::ClientPort>> GetServicePort(const std::string& name);
|
|
|
|
ResultVal<Kernel::SharedPtr<Kernel::ClientSession>> ConnectToService(const std::string& name);
|
|
|
|
|
2017-10-15 02:18:42 +00:00
|
|
|
void InvokeControlRequest(Kernel::HLERequestContext& context);
|
|
|
|
|
2017-06-06 06:31:59 +00:00
|
|
|
private:
|
2017-10-15 02:18:42 +00:00
|
|
|
std::weak_ptr<SM> sm_interface;
|
|
|
|
std::unique_ptr<Controller> controller_interface;
|
2017-06-07 04:25:28 +00:00
|
|
|
|
|
|
|
/// Map of registered services, retrieved using GetServicePort or ConnectToService.
|
2017-06-06 06:31:59 +00:00
|
|
|
std::unordered_map<std::string, Kernel::SharedPtr<Kernel::ClientPort>> registered_services;
|
|
|
|
};
|
|
|
|
|
2017-06-07 04:25:28 +00:00
|
|
|
extern std::shared_ptr<ServiceManager> g_service_manager;
|
2017-06-06 06:31:59 +00:00
|
|
|
|
2018-04-20 01:41:44 +00:00
|
|
|
} // namespace Service::SM
|