mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-12-27 01:22:37 -06:00
Service, Kernel: move named port list to kernel
This commit is contained in:
parent
ece96807c4
commit
fc84091d88
6 changed files with 18 additions and 30 deletions
|
@ -256,7 +256,6 @@ void System::Shutdown() {
|
||||||
// Shutdown emulation session
|
// Shutdown emulation session
|
||||||
GDBStub::Shutdown();
|
GDBStub::Shutdown();
|
||||||
VideoCore::Shutdown();
|
VideoCore::Shutdown();
|
||||||
Service::Shutdown();
|
|
||||||
kernel.reset();
|
kernel.reset();
|
||||||
HW::Shutdown();
|
HW::Shutdown();
|
||||||
telemetry_session.reset();
|
telemetry_session.reset();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "core/hle/kernel/client_port.h"
|
||||||
#include "core/hle/kernel/config_mem.h"
|
#include "core/hle/kernel/config_mem.h"
|
||||||
#include "core/hle/kernel/handle_table.h"
|
#include "core/hle/kernel/handle_table.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
|
@ -70,4 +71,8 @@ const SharedPage::Handler& KernelSystem::GetSharedPageHandler() const {
|
||||||
return *shared_page_handler;
|
return *shared_page_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KernelSystem::AddNamedPort(std::string name, SharedPtr<ClientPort> port) {
|
||||||
|
named_ports.emplace(std::move(name), std::move(port));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Kernel
|
} // namespace Kernel
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/smart_ptr/intrusive_ptr.hpp>
|
#include <boost/smart_ptr/intrusive_ptr.hpp>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
@ -215,6 +216,12 @@ public:
|
||||||
|
|
||||||
std::array<MemoryRegionInfo, 3> memory_regions;
|
std::array<MemoryRegionInfo, 3> memory_regions;
|
||||||
|
|
||||||
|
/// Adds a port to the named port table
|
||||||
|
void AddNamedPort(std::string name, SharedPtr<ClientPort> port);
|
||||||
|
|
||||||
|
/// Map of named ports managed by the kernel, which can be retrieved using the ConnectToPort
|
||||||
|
std::unordered_map<std::string, SharedPtr<ClientPort>> named_ports;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void MemoryInit(u32 mem_type);
|
void MemoryInit(u32 mem_type);
|
||||||
|
|
||||||
|
|
|
@ -235,8 +235,10 @@ static ResultCode ConnectToPort(Handle* out_handle, VAddr port_name_address) {
|
||||||
|
|
||||||
LOG_TRACE(Kernel_SVC, "called port_name={}", port_name);
|
LOG_TRACE(Kernel_SVC, "called port_name={}", port_name);
|
||||||
|
|
||||||
auto it = Service::g_kernel_named_ports.find(port_name);
|
KernelSystem& kernel = Core::System::GetInstance().Kernel();
|
||||||
if (it == Service::g_kernel_named_ports.end()) {
|
|
||||||
|
auto it = kernel.named_ports.find(port_name);
|
||||||
|
if (it == kernel.named_ports.end()) {
|
||||||
LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: {}", port_name);
|
LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: {}", port_name);
|
||||||
return ERR_NOT_FOUND;
|
return ERR_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
@ -247,9 +249,7 @@ static ResultCode ConnectToPort(Handle* out_handle, VAddr port_name_address) {
|
||||||
CASCADE_RESULT(client_session, client_port->Connect());
|
CASCADE_RESULT(client_session, client_port->Connect());
|
||||||
|
|
||||||
// Return the client session
|
// Return the client session
|
||||||
CASCADE_RESULT(*out_handle,
|
CASCADE_RESULT(*out_handle, kernel.GetCurrentProcess()->handle_table.Create(client_session));
|
||||||
Core::System::GetInstance().Kernel().GetCurrentProcess()->handle_table.Create(
|
|
||||||
client_session));
|
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,6 @@ using Kernel::SharedPtr;
|
||||||
|
|
||||||
namespace Service {
|
namespace Service {
|
||||||
|
|
||||||
std::unordered_map<std::string, SharedPtr<ClientPort>> g_kernel_named_ports;
|
|
||||||
|
|
||||||
const std::array<ServiceModuleInfo, 40> service_module_map{
|
const std::array<ServiceModuleInfo, 40> service_module_map{
|
||||||
{{"FS", 0x00040130'00001102, FS::InstallInterfaces},
|
{{"FS", 0x00040130'00001102, FS::InstallInterfaces},
|
||||||
{"PM", 0x00040130'00001202, PM::InstallInterfaces},
|
{"PM", 0x00040130'00001202, PM::InstallInterfaces},
|
||||||
|
@ -149,7 +147,7 @@ void ServiceFrameworkBase::InstallAsNamedPort(Kernel::KernelSystem& kernel) {
|
||||||
SharedPtr<ClientPort> client_port;
|
SharedPtr<ClientPort> client_port;
|
||||||
std::tie(server_port, client_port) = kernel.CreatePortPair(max_sessions, service_name);
|
std::tie(server_port, client_port) = kernel.CreatePortPair(max_sessions, service_name);
|
||||||
server_port->SetHleHandler(shared_from_this());
|
server_port->SetHleHandler(shared_from_this());
|
||||||
AddNamedPort(service_name, std::move(client_port));
|
kernel.AddNamedPort(service_name, std::move(client_port));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n) {
|
void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n) {
|
||||||
|
@ -214,11 +212,6 @@ void ServiceFrameworkBase::HandleSyncRequest(SharedPtr<ServerSession> server_ses
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Module interface
|
// Module interface
|
||||||
|
|
||||||
// TODO(yuriks): Move to kernel
|
|
||||||
void AddNamedPort(std::string name, SharedPtr<ClientPort> port) {
|
|
||||||
g_kernel_named_ports.emplace(std::move(name), std::move(port));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool AttemptLLE(const ServiceModuleInfo& service_module) {
|
static bool AttemptLLE(const ServiceModuleInfo& service_module) {
|
||||||
if (!Settings::values.lle_modules.at(service_module.name))
|
if (!Settings::values.lle_modules.at(service_module.name))
|
||||||
return false;
|
return false;
|
||||||
|
@ -247,10 +240,4 @@ void Init(Core::System& core) {
|
||||||
LOG_DEBUG(Service, "initialized OK");
|
LOG_DEBUG(Service, "initialized OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shutdown ServiceManager
|
|
||||||
void Shutdown() {
|
|
||||||
|
|
||||||
g_kernel_named_ports.clear();
|
|
||||||
LOG_DEBUG(Service, "shutdown OK");
|
|
||||||
}
|
|
||||||
} // namespace Service
|
} // namespace Service
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
|
||||||
#include <boost/container/flat_map.hpp>
|
#include <boost/container/flat_map.hpp>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/hle/kernel/hle_ipc.h"
|
#include "core/hle/kernel/hle_ipc.h"
|
||||||
|
@ -187,12 +186,6 @@ private:
|
||||||
/// Initialize ServiceManager
|
/// Initialize ServiceManager
|
||||||
void Init(Core::System& system);
|
void Init(Core::System& system);
|
||||||
|
|
||||||
/// Shutdown ServiceManager
|
|
||||||
void Shutdown();
|
|
||||||
|
|
||||||
/// Map of named ports managed by the kernel, which can be retrieved using the ConnectToPort SVC.
|
|
||||||
extern std::unordered_map<std::string, Kernel::SharedPtr<Kernel::ClientPort>> g_kernel_named_ports;
|
|
||||||
|
|
||||||
struct ServiceModuleInfo {
|
struct ServiceModuleInfo {
|
||||||
std::string name;
|
std::string name;
|
||||||
u64 title_id;
|
u64 title_id;
|
||||||
|
@ -201,7 +194,4 @@ struct ServiceModuleInfo {
|
||||||
|
|
||||||
extern const std::array<ServiceModuleInfo, 40> service_module_map;
|
extern const std::array<ServiceModuleInfo, 40> service_module_map;
|
||||||
|
|
||||||
/// Adds a port to the named port table
|
|
||||||
void AddNamedPort(std::string name, Kernel::SharedPtr<Kernel::ClientPort> port);
|
|
||||||
|
|
||||||
} // namespace Service
|
} // namespace Service
|
||||||
|
|
Loading…
Reference in a new issue