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();