erpt: update for new sf semantics

This commit is contained in:
Michael Scire 2021-01-17 22:55:39 -08:00
parent a6e452ed9e
commit 4f001b4f4c
2 changed files with 50 additions and 3 deletions

View File

@ -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<typename RemoteAllocator::Policy>;
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<const u16 *>(dependencies), dependency_count, clear_mode == os::EventClearMode_AutoClear));
/* TODO: Proper allocator */
this->intf = ams::sf::CreateSharedObjectEmplaced<psc::sf::IPmModule, RemotePmModule>(module);
this->intf = RemoteObjectFactory::CreateSharedEmplaced<psc::sf::IPmModule, RemotePmModule>(module);
this->system_event.AttachReadableHandle(module.event.revent, false, clear_mode);
this->initialized = true;
return ResultSuccess();

View File

@ -21,7 +21,7 @@ extern "C" {
u32 __nx_applet_type = AppletType_None;
u32 __nx_fs_num_sessions = 1;
#define INNER_HEAP_SIZE 0x4000
#define INNER_HEAP_SIZE 0x0
size_t nx_inner_heap_size = INNER_HEAP_SIZE;
char nx_inner_heap[INNER_HEAP_SIZE];
@ -33,6 +33,10 @@ extern "C" {
alignas(16) u8 __nx_exception_stack[ams::os::MemoryPageSize];
u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
void __libnx_exception_handler(ThreadExceptionDump *ctx);
void *__libnx_thread_alloc(size_t size);
void __libnx_thread_free(void *mem);
}
namespace ams {
@ -121,6 +125,34 @@ namespace ams::erpt {
}
namespace ams {
void *Malloc(size_t size) {
AMS_ABORT("ams::Malloc was called");
}
void Free(void *ptr) {
AMS_ABORT("ams::Free was called");
}
}
void *operator new(size_t size) {
AMS_ABORT("operator new(size_t) was called");
}
void operator delete(void *p) {
AMS_ABORT("operator delete(void *) was called");
}
void *__libnx_thread_alloc(size_t size) {
AMS_ABORT("__libnx_thread_alloc was called");
}
void __libnx_thread_free(void *mem) {
AMS_ABORT("__libnx_thread_free was called");
}
int main(int argc, char **argv)
{
/* Set thread name. */