From 9ce7e67114f128698805346c07325d638ce7272f Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sun, 17 Jan 2021 22:55:39 -0800 Subject: [PATCH] erpt: update for new sf semantics --- .../source/psc/psc_pm_module.os.horizon.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libstratosphere/source/psc/psc_pm_module.os.horizon.cpp b/libstratosphere/source/psc/psc_pm_module.os.horizon.cpp index f4523ada..e808dbf2 100644 --- a/libstratosphere/source/psc/psc_pm_module.os.horizon.cpp +++ b/libstratosphere/source/psc/psc_pm_module.os.horizon.cpp @@ -18,6 +18,22 @@ namespace ams::psc { + /* TODO: Nintendo uses sf::ShimLobraryObjectHolder here, we should similarly consider switching. */ + namespace { + + struct PscRemotePmModuleTag; + using RemoteAllocator = ams::sf::ExpHeapStaticAllocator<2_KB, PscRemotePmModuleTag>; + using RemoteObjectFactory = ams::sf::ObjectFactory; + + class StaticAllocatorInitializer { + public: + StaticAllocatorInitializer() { + RemoteAllocator::Initialize(lmem::CreateOption_None); + } + } g_static_allocator_initializer; + + } + PmModule::PmModule() : intf(nullptr), initialized(false), reserved(0) { /* ... */ } PmModule::~PmModule() { @@ -34,8 +50,7 @@ namespace ams::psc { ::PscPmModule module; R_TRY(::pscmGetPmModule(std::addressof(module), static_cast<::PscPmModuleId>(mid), reinterpret_cast(dependencies), dependency_count, clear_mode == os::EventClearMode_AutoClear)); - /* TODO: Proper allocator */ - this->intf = ams::sf::CreateSharedObjectEmplaced(module); + this->intf = RemoteObjectFactory::CreateSharedEmplaced(module); this->system_event.AttachReadableHandle(module.event.revent, false, clear_mode); this->initialized = true; return ResultSuccess();