mirror of
https://github.com/PabloMK7/citra
synced 2024-11-15 05:08:23 +00:00
Merge pull request #4389 from wwylele/kernel-global-4
Kernel: clean up the rest of global states
This commit is contained in:
commit
7c3d325aff
20 changed files with 113 additions and 108 deletions
|
@ -103,8 +103,6 @@ add_library(core STATIC
|
|||
hle/applets/mint.h
|
||||
hle/applets/swkbd.cpp
|
||||
hle/applets/swkbd.h
|
||||
hle/config_mem.cpp
|
||||
hle/config_mem.h
|
||||
hle/function_wrappers.h
|
||||
hle/ipc.h
|
||||
hle/ipc_helpers.h
|
||||
|
@ -114,6 +112,8 @@ add_library(core STATIC
|
|||
hle/kernel/client_port.h
|
||||
hle/kernel/client_session.cpp
|
||||
hle/kernel/client_session.h
|
||||
hle/kernel/config_mem.cpp
|
||||
hle/kernel/config_mem.h
|
||||
hle/kernel/errors.h
|
||||
hle/kernel/event.cpp
|
||||
hle/kernel/event.h
|
||||
|
@ -144,6 +144,8 @@ add_library(core STATIC
|
|||
hle/kernel/session.h
|
||||
hle/kernel/shared_memory.cpp
|
||||
hle/kernel/shared_memory.h
|
||||
hle/kernel/shared_page.cpp
|
||||
hle/kernel/shared_page.h
|
||||
hle/kernel/svc.cpp
|
||||
hle/kernel/svc.h
|
||||
hle/kernel/thread.cpp
|
||||
|
@ -386,8 +388,6 @@ add_library(core STATIC
|
|||
hle/service/ssl_c.h
|
||||
hle/service/y2r_u.cpp
|
||||
hle/service/y2r_u.h
|
||||
hle/shared_page.cpp
|
||||
hle/shared_page.h
|
||||
hw/aes/arithmetic128.cpp
|
||||
hw/aes/arithmetic128.h
|
||||
hw/aes/ccm.cpp
|
||||
|
|
|
@ -194,7 +194,6 @@ System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) {
|
|||
#endif
|
||||
|
||||
service_manager = std::make_shared<Service::SM::ServiceManager>(*this);
|
||||
shared_page_handler = std::make_shared<SharedPage::Handler>();
|
||||
archive_manager = std::make_unique<Service::FS::ArchiveManager>(*this);
|
||||
|
||||
HW::Init();
|
||||
|
@ -257,7 +256,6 @@ void System::Shutdown() {
|
|||
// Shutdown emulation session
|
||||
GDBStub::Shutdown();
|
||||
VideoCore::Shutdown();
|
||||
Service::Shutdown();
|
||||
kernel.reset();
|
||||
HW::Shutdown();
|
||||
telemetry_session.reset();
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <string>
|
||||
#include "common/common_types.h"
|
||||
#include "core/frontend/applets/swkbd.h"
|
||||
#include "core/hle/shared_page.h"
|
||||
#include "core/loader/loader.h"
|
||||
#include "core/memory.h"
|
||||
#include "core/perf_stats.h"
|
||||
|
@ -203,10 +202,6 @@ public:
|
|||
return registered_swkbd;
|
||||
}
|
||||
|
||||
std::shared_ptr<SharedPage::Handler> GetSharedPageHandler() const {
|
||||
return shared_page_handler;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Initialize the emulated system.
|
||||
|
@ -246,9 +241,6 @@ private:
|
|||
std::unique_ptr<RPC::RPCServer> rpc_server;
|
||||
#endif
|
||||
|
||||
/// Shared Page
|
||||
std::shared_ptr<SharedPage::Handler> shared_page_handler;
|
||||
|
||||
std::unique_ptr<Service::FS::ArchiveManager> archive_manager;
|
||||
|
||||
public: // HACK: this is temporary exposed for tests,
|
||||
|
|
|
@ -3,15 +3,13 @@
|
|||
// Refer to the license.txt file included.
|
||||
|
||||
#include <cstring>
|
||||
#include "core/hle/config_mem.h"
|
||||
#include "core/hle/kernel/config_mem.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace ConfigMem {
|
||||
|
||||
ConfigMemDef config_mem;
|
||||
|
||||
void Init() {
|
||||
Handler::Handler() {
|
||||
std::memset(&config_mem, 0, sizeof(config_mem));
|
||||
|
||||
// Values extracted from firmware 11.2.0-35E
|
||||
|
@ -28,4 +26,8 @@ void Init() {
|
|||
config_mem.firm_ctr_sdk_ver = 0x0000F297;
|
||||
}
|
||||
|
||||
ConfigMemDef& Handler::GetConfigMem() {
|
||||
return config_mem;
|
||||
}
|
||||
|
||||
} // namespace ConfigMem
|
|
@ -49,8 +49,13 @@ struct ConfigMemDef {
|
|||
static_assert(sizeof(ConfigMemDef) == Memory::CONFIG_MEMORY_SIZE,
|
||||
"Config Memory structure size is wrong");
|
||||
|
||||
extern ConfigMemDef config_mem;
|
||||
class Handler {
|
||||
public:
|
||||
Handler();
|
||||
ConfigMemDef& GetConfigMem();
|
||||
|
||||
void Init();
|
||||
private:
|
||||
ConfigMemDef config_mem;
|
||||
};
|
||||
|
||||
} // namespace ConfigMem
|
|
@ -2,23 +2,22 @@
|
|||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "core/hle/config_mem.h"
|
||||
#include "core/hle/kernel/client_port.h"
|
||||
#include "core/hle/kernel/config_mem.h"
|
||||
#include "core/hle/kernel/handle_table.h"
|
||||
#include "core/hle/kernel/kernel.h"
|
||||
#include "core/hle/kernel/memory.h"
|
||||
#include "core/hle/kernel/process.h"
|
||||
#include "core/hle/kernel/resource_limit.h"
|
||||
#include "core/hle/kernel/shared_page.h"
|
||||
#include "core/hle/kernel/thread.h"
|
||||
#include "core/hle/kernel/timer.h"
|
||||
#include "core/hle/shared_page.h"
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
/// Initialize the kernel
|
||||
KernelSystem::KernelSystem(u32 system_mode) {
|
||||
ConfigMem::Init();
|
||||
|
||||
Kernel::MemoryInit(system_mode);
|
||||
MemoryInit(system_mode);
|
||||
|
||||
resource_limits = std::make_unique<ResourceLimitList>(*this);
|
||||
thread_manager = std::make_unique<ThreadManager>();
|
||||
|
@ -26,9 +25,7 @@ KernelSystem::KernelSystem(u32 system_mode) {
|
|||
}
|
||||
|
||||
/// Shutdown the kernel
|
||||
KernelSystem::~KernelSystem() {
|
||||
Kernel::MemoryShutdown();
|
||||
}
|
||||
KernelSystem::~KernelSystem() = default;
|
||||
|
||||
ResourceLimitList& KernelSystem::ResourceLimit() {
|
||||
return *resource_limits;
|
||||
|
@ -66,4 +63,16 @@ const TimerManager& KernelSystem::GetTimerManager() const {
|
|||
return *timer_manager;
|
||||
}
|
||||
|
||||
SharedPage::Handler& KernelSystem::GetSharedPageHandler() {
|
||||
return *shared_page_handler;
|
||||
}
|
||||
|
||||
const SharedPage::Handler& KernelSystem::GetSharedPageHandler() const {
|
||||
return *shared_page_handler;
|
||||
}
|
||||
|
||||
void KernelSystem::AddNamedPort(std::string name, SharedPtr<ClientPort> port) {
|
||||
named_ports.emplace(std::move(name), std::move(port));
|
||||
}
|
||||
|
||||
} // namespace Kernel
|
||||
|
|
|
@ -4,14 +4,25 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <boost/smart_ptr/intrusive_ptr.hpp>
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/kernel/memory.h"
|
||||
#include "core/hle/result.h"
|
||||
|
||||
namespace ConfigMem {
|
||||
class Handler;
|
||||
}
|
||||
|
||||
namespace SharedPage {
|
||||
class Handler;
|
||||
}
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class AddressArbiter;
|
||||
|
@ -30,6 +41,7 @@ class ResourceLimitList;
|
|||
class SharedMemory;
|
||||
class ThreadManager;
|
||||
class TimerManager;
|
||||
class VMManager;
|
||||
|
||||
enum class ResetType {
|
||||
OneShot,
|
||||
|
@ -195,7 +207,24 @@ public:
|
|||
TimerManager& GetTimerManager();
|
||||
const TimerManager& GetTimerManager() const;
|
||||
|
||||
void MapSharedPages(VMManager& address_space);
|
||||
|
||||
SharedPage::Handler& GetSharedPageHandler();
|
||||
const SharedPage::Handler& GetSharedPageHandler() const;
|
||||
|
||||
MemoryRegionInfo* GetMemoryRegion(MemoryRegion region);
|
||||
|
||||
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:
|
||||
void MemoryInit(u32 mem_type);
|
||||
|
||||
std::unique_ptr<ResourceLimitList> resource_limits;
|
||||
std::atomic<u32> next_object_id{0};
|
||||
|
||||
|
@ -210,6 +239,9 @@ private:
|
|||
|
||||
std::unique_ptr<ThreadManager> thread_manager;
|
||||
std::unique_ptr<TimerManager> timer_manager;
|
||||
|
||||
std::unique_ptr<ConfigMem::Handler> config_mem_handler;
|
||||
std::unique_ptr<SharedPage::Handler> shared_page_handler;
|
||||
};
|
||||
|
||||
} // namespace Kernel
|
||||
|
|
|
@ -12,8 +12,10 @@
|
|||
#include "common/common_types.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/config_mem.h"
|
||||
#include "core/hle/kernel/config_mem.h"
|
||||
#include "core/hle/kernel/memory.h"
|
||||
#include "core/hle/kernel/process.h"
|
||||
#include "core/hle/kernel/shared_page.h"
|
||||
#include "core/hle/kernel/vm_manager.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/memory.h"
|
||||
|
@ -23,8 +25,6 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
MemoryRegionInfo memory_regions[3];
|
||||
|
||||
/// Size of the APPLICATION, SYSTEM and BASE memory regions (respectively) for each system
|
||||
/// memory configuration type.
|
||||
static const u32 memory_region_sizes[8][3] = {
|
||||
|
@ -41,7 +41,7 @@ static const u32 memory_region_sizes[8][3] = {
|
|||
{0x0B200000, 0x02E00000, 0x02000000}, // 7
|
||||
};
|
||||
|
||||
void MemoryInit(u32 mem_type) {
|
||||
void KernelSystem::MemoryInit(u32 mem_type) {
|
||||
// TODO(yuriks): On the n3DS, all o3DS configurations (<=5) are forced to 6 instead.
|
||||
ASSERT_MSG(mem_type <= 5, "New 3DS memory configuration aren't supported yet!");
|
||||
ASSERT(mem_type != 1);
|
||||
|
@ -64,25 +64,19 @@ void MemoryInit(u32 mem_type) {
|
|||
// We must've allocated the entire FCRAM by the end
|
||||
ASSERT(base == Memory::FCRAM_SIZE);
|
||||
|
||||
using ConfigMem::config_mem;
|
||||
config_mem_handler = std::make_unique<ConfigMem::Handler>();
|
||||
auto& config_mem = config_mem_handler->GetConfigMem();
|
||||
config_mem.app_mem_type = mem_type;
|
||||
// app_mem_malloc does not always match the configured size for memory_region[0]: in case the
|
||||
// n3DS type override is in effect it reports the size the game expects, not the real one.
|
||||
config_mem.app_mem_alloc = memory_region_sizes[mem_type][0];
|
||||
config_mem.sys_mem_alloc = memory_regions[1].size;
|
||||
config_mem.base_mem_alloc = memory_regions[2].size;
|
||||
|
||||
shared_page_handler = std::make_unique<SharedPage::Handler>();
|
||||
}
|
||||
|
||||
void MemoryShutdown() {
|
||||
for (auto& region : memory_regions) {
|
||||
region.base = 0;
|
||||
region.size = 0;
|
||||
region.used = 0;
|
||||
region.linear_heap_memory = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
MemoryRegionInfo* GetMemoryRegion(MemoryRegion region) {
|
||||
MemoryRegionInfo* KernelSystem::GetMemoryRegion(MemoryRegion region) {
|
||||
switch (region) {
|
||||
case MemoryRegion::APPLICATION:
|
||||
return &memory_regions[0];
|
||||
|
@ -152,20 +146,19 @@ void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mappin
|
|||
mapping.read_only ? VMAPermission::Read : VMAPermission::ReadWrite);
|
||||
}
|
||||
|
||||
void MapSharedPages(VMManager& address_space) {
|
||||
auto cfg_mem_vma = address_space
|
||||
void KernelSystem::MapSharedPages(VMManager& address_space) {
|
||||
auto cfg_mem_vma =
|
||||
address_space
|
||||
.MapBackingMemory(Memory::CONFIG_MEMORY_VADDR,
|
||||
reinterpret_cast<u8*>(&ConfigMem::config_mem),
|
||||
reinterpret_cast<u8*>(&config_mem_handler->GetConfigMem()),
|
||||
Memory::CONFIG_MEMORY_SIZE, MemoryState::Shared)
|
||||
.Unwrap();
|
||||
address_space.Reprotect(cfg_mem_vma, VMAPermission::Read);
|
||||
|
||||
auto shared_page_vma =
|
||||
address_space
|
||||
.MapBackingMemory(
|
||||
Memory::SHARED_PAGE_VADDR,
|
||||
reinterpret_cast<u8*>(
|
||||
&Core::System::GetInstance().GetSharedPageHandler()->GetSharedPage()),
|
||||
.MapBackingMemory(Memory::SHARED_PAGE_VADDR,
|
||||
reinterpret_cast<u8*>(&shared_page_handler->GetSharedPage()),
|
||||
Memory::SHARED_PAGE_SIZE, MemoryState::Shared)
|
||||
.Unwrap();
|
||||
address_space.Reprotect(shared_page_vma, VMAPermission::Read);
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/kernel/process.h"
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
struct AddressMapping;
|
||||
class VMManager;
|
||||
|
||||
struct MemoryRegionInfo {
|
||||
|
@ -20,12 +21,6 @@ struct MemoryRegionInfo {
|
|||
std::shared_ptr<std::vector<u8>> linear_heap_memory;
|
||||
};
|
||||
|
||||
void MemoryInit(u32 mem_type);
|
||||
void MemoryShutdown();
|
||||
MemoryRegionInfo* GetMemoryRegion(MemoryRegion region);
|
||||
|
||||
void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mapping);
|
||||
void MapSharedPages(VMManager& address_space);
|
||||
|
||||
extern MemoryRegionInfo memory_regions[3];
|
||||
} // namespace Kernel
|
||||
|
|
|
@ -115,7 +115,7 @@ void Process::ParseKernelCaps(const u32* kernel_caps, std::size_t len) {
|
|||
}
|
||||
|
||||
void Process::Run(s32 main_thread_priority, u32 stack_size) {
|
||||
memory_region = GetMemoryRegion(flags.memory_region);
|
||||
memory_region = kernel.GetMemoryRegion(flags.memory_region);
|
||||
|
||||
auto MapSegment = [&](CodeSet::Segment& segment, VMAPermission permissions,
|
||||
MemoryState memory_state) {
|
||||
|
@ -143,7 +143,7 @@ void Process::Run(s32 main_thread_priority, u32 stack_size) {
|
|||
memory_region->used += stack_size;
|
||||
|
||||
// Map special address mappings
|
||||
MapSharedPages(vm_manager);
|
||||
kernel.MapSharedPages(vm_manager);
|
||||
for (const auto& mapping : address_mappings) {
|
||||
HandleSpecialMapping(vm_manager, mapping);
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include <chrono>
|
||||
#include <cstring>
|
||||
#include "core/core_timing.h"
|
||||
#include "core/hle/kernel/shared_page.h"
|
||||
#include "core/hle/service/ptm/ptm.h"
|
||||
#include "core/hle/shared_page.h"
|
||||
#include "core/movie.h"
|
||||
#include "core/settings.h"
|
||||
|
|
@ -235,8 +235,10 @@ static ResultCode ConnectToPort(Handle* out_handle, VAddr port_name_address) {
|
|||
|
||||
LOG_TRACE(Kernel_SVC, "called port_name={}", port_name);
|
||||
|
||||
auto it = Service::g_kernel_named_ports.find(port_name);
|
||||
if (it == Service::g_kernel_named_ports.end()) {
|
||||
KernelSystem& kernel = Core::System::GetInstance().Kernel();
|
||||
|
||||
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);
|
||||
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());
|
||||
|
||||
// Return the client session
|
||||
CASCADE_RESULT(*out_handle,
|
||||
Core::System::GetInstance().Kernel().GetCurrentProcess()->handle_table.Create(
|
||||
client_session));
|
||||
CASCADE_RESULT(*out_handle, kernel.GetCurrentProcess()->handle_table.Create(client_session));
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1233,22 +1233,24 @@ static ResultCode AcceptSession(Handle* out_server_session, Handle server_port_h
|
|||
static ResultCode GetSystemInfo(s64* out, u32 type, s32 param) {
|
||||
LOG_TRACE(Kernel_SVC, "called type={} param={}", type, param);
|
||||
|
||||
KernelSystem& kernel = Core::System::GetInstance().Kernel();
|
||||
|
||||
switch ((SystemInfoType)type) {
|
||||
case SystemInfoType::REGION_MEMORY_USAGE:
|
||||
switch ((SystemInfoMemUsageRegion)param) {
|
||||
case SystemInfoMemUsageRegion::ALL:
|
||||
*out = GetMemoryRegion(MemoryRegion::APPLICATION)->used +
|
||||
GetMemoryRegion(MemoryRegion::SYSTEM)->used +
|
||||
GetMemoryRegion(MemoryRegion::BASE)->used;
|
||||
*out = kernel.GetMemoryRegion(MemoryRegion::APPLICATION)->used +
|
||||
kernel.GetMemoryRegion(MemoryRegion::SYSTEM)->used +
|
||||
kernel.GetMemoryRegion(MemoryRegion::BASE)->used;
|
||||
break;
|
||||
case SystemInfoMemUsageRegion::APPLICATION:
|
||||
*out = GetMemoryRegion(MemoryRegion::APPLICATION)->used;
|
||||
*out = kernel.GetMemoryRegion(MemoryRegion::APPLICATION)->used;
|
||||
break;
|
||||
case SystemInfoMemUsageRegion::SYSTEM:
|
||||
*out = GetMemoryRegion(MemoryRegion::SYSTEM)->used;
|
||||
*out = kernel.GetMemoryRegion(MemoryRegion::SYSTEM)->used;
|
||||
break;
|
||||
case SystemInfoMemUsageRegion::BASE:
|
||||
*out = GetMemoryRegion(MemoryRegion::BASE)->used;
|
||||
*out = kernel.GetMemoryRegion(MemoryRegion::BASE)->used;
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR(Kernel_SVC, "unknown GetSystemInfo type=0 region: param={}", param);
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <algorithm>
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/config_mem.h"
|
||||
#include "core/hle/kernel/errors.h"
|
||||
#include "core/hle/kernel/kernel.h"
|
||||
#include "core/hle/kernel/memory.h"
|
||||
|
@ -13,7 +12,6 @@
|
|||
#include "core/hle/kernel/resource_limit.h"
|
||||
#include "core/hle/kernel/thread.h"
|
||||
#include "core/hle/kernel/timer.h"
|
||||
#include "core/hle/shared_page.h"
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/kernel/handle_table.h"
|
||||
#include "core/hle/kernel/shared_memory.h"
|
||||
#include "core/hle/kernel/shared_page.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/hle/service/gsp/gsp_gpu.h"
|
||||
#include "core/hw/gpu.h"
|
||||
|
@ -731,7 +732,7 @@ void GSP_GPU::SetLedForceOff(Kernel::HLERequestContext& ctx) {
|
|||
|
||||
u8 state = rp.Pop<u8>();
|
||||
|
||||
system.GetSharedPageHandler()->Set3DLed(state);
|
||||
system.Kernel().GetSharedPageHandler().Set3DLed(state);
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/kernel/shared_memory.h"
|
||||
#include "core/hle/kernel/shared_page.h"
|
||||
#include "core/hle/lock.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/hle/service/nwm/nwm_uds.h"
|
||||
|
@ -1407,8 +1408,8 @@ NWM_UDS::NWM_UDS(Core::System& system) : ServiceFramework("nwm::UDS"), system(sy
|
|||
}
|
||||
}
|
||||
|
||||
system.GetSharedPageHandler()->SetMacAddress(mac);
|
||||
system.GetSharedPageHandler()->SetWifiLinkLevel(SharedPage::WifiLinkLevel::BEST);
|
||||
system.Kernel().GetSharedPageHandler().SetMacAddress(mac);
|
||||
system.Kernel().GetSharedPageHandler().SetWifiLinkLevel(SharedPage::WifiLinkLevel::BEST);
|
||||
}
|
||||
|
||||
NWM_UDS::~NWM_UDS() {
|
||||
|
|
|
@ -61,8 +61,6 @@ using Kernel::SharedPtr;
|
|||
|
||||
namespace Service {
|
||||
|
||||
std::unordered_map<std::string, SharedPtr<ClientPort>> g_kernel_named_ports;
|
||||
|
||||
const std::array<ServiceModuleInfo, 40> service_module_map{
|
||||
{{"FS", 0x00040130'00001102, FS::InstallInterfaces},
|
||||
{"PM", 0x00040130'00001202, PM::InstallInterfaces},
|
||||
|
@ -149,7 +147,7 @@ void ServiceFrameworkBase::InstallAsNamedPort(Kernel::KernelSystem& kernel) {
|
|||
SharedPtr<ClientPort> client_port;
|
||||
std::tie(server_port, client_port) = kernel.CreatePortPair(max_sessions, service_name);
|
||||
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) {
|
||||
|
@ -214,11 +212,6 @@ void ServiceFrameworkBase::HandleSyncRequest(SharedPtr<ServerSession> server_ses
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 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) {
|
||||
if (!Settings::values.lle_modules.at(service_module.name))
|
||||
return false;
|
||||
|
@ -247,10 +240,4 @@ void Init(Core::System& core) {
|
|||
LOG_DEBUG(Service, "initialized OK");
|
||||
}
|
||||
|
||||
/// Shutdown ServiceManager
|
||||
void Shutdown() {
|
||||
|
||||
g_kernel_named_ports.clear();
|
||||
LOG_DEBUG(Service, "shutdown OK");
|
||||
}
|
||||
} // namespace Service
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <boost/container/flat_map.hpp>
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/kernel/hle_ipc.h"
|
||||
|
@ -187,12 +186,6 @@ private:
|
|||
/// Initialize ServiceManager
|
||||
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 {
|
||||
std::string name;
|
||||
u64 title_id;
|
||||
|
@ -201,7 +194,4 @@ struct ServiceModuleInfo {
|
|||
|
||||
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
|
||||
|
|
|
@ -305,7 +305,7 @@ u8* GetPhysicalPointer(PAddr address) {
|
|||
target_pointer = Core::DSP().GetDspMemory().data() + offset_into_region;
|
||||
break;
|
||||
case FCRAM_PADDR:
|
||||
for (const auto& region : Kernel::memory_regions) {
|
||||
for (const auto& region : Core::System::GetInstance().Kernel().memory_regions) {
|
||||
if (offset_into_region >= region.base &&
|
||||
offset_into_region < region.base + region.size) {
|
||||
target_pointer =
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "core/core_timing.h"
|
||||
#include "core/hle/kernel/memory.h"
|
||||
#include "core/hle/kernel/process.h"
|
||||
#include "core/hle/shared_page.h"
|
||||
#include "core/hle/kernel/shared_page.h"
|
||||
#include "core/memory.h"
|
||||
|
||||
TEST_CASE("Memory::IsValidVirtualAddress", "[core][memory]") {
|
||||
|
@ -25,7 +25,7 @@ TEST_CASE("Memory::IsValidVirtualAddress", "[core][memory]") {
|
|||
|
||||
SECTION("CONFIG_MEMORY_VADDR and SHARED_PAGE_VADDR should be valid after mapping them") {
|
||||
auto process = kernel.CreateProcess(kernel.CreateCodeSet("", 0));
|
||||
Kernel::MapSharedPages(process->vm_manager);
|
||||
kernel.MapSharedPages(process->vm_manager);
|
||||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::CONFIG_MEMORY_VADDR) == true);
|
||||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::SHARED_PAGE_VADDR) == true);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ TEST_CASE("Memory::IsValidVirtualAddress", "[core][memory]") {
|
|||
|
||||
SECTION("Unmapping a VAddr should make it invalid") {
|
||||
auto process = kernel.CreateProcess(kernel.CreateCodeSet("", 0));
|
||||
Kernel::MapSharedPages(process->vm_manager);
|
||||
kernel.MapSharedPages(process->vm_manager);
|
||||
process->vm_manager.UnmapRange(Memory::CONFIG_MEMORY_VADDR, Memory::CONFIG_MEMORY_SIZE);
|
||||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::CONFIG_MEMORY_VADDR) == false);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue