mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-24 11:16:11 +00:00
ncm: update for new sf semantics
This commit is contained in:
parent
2c485f832c
commit
54a1ba2a7e
2 changed files with 49 additions and 30 deletions
|
@ -24,7 +24,7 @@ namespace ams::ncm {
|
||||||
void Initialize();
|
void Initialize();
|
||||||
void Finalize();
|
void Finalize();
|
||||||
|
|
||||||
void InitializeWithObject(std::shared_ptr<IContentManager> manager_object);
|
void InitializeWithObject(sf::SharedPointer<IContentManager> manager_object);
|
||||||
|
|
||||||
/* Service API. */
|
/* Service API. */
|
||||||
Result CreateContentStorage(StorageId storage_id);
|
Result CreateContentStorage(StorageId storage_id);
|
||||||
|
|
|
@ -21,7 +21,7 @@ extern "C" {
|
||||||
u32 __nx_applet_type = AppletType_None;
|
u32 __nx_applet_type = AppletType_None;
|
||||||
u32 __nx_fs_num_sessions = 2;
|
u32 __nx_fs_num_sessions = 2;
|
||||||
|
|
||||||
#define INNER_HEAP_SIZE 0x8000
|
#define INNER_HEAP_SIZE 0x0
|
||||||
size_t nx_inner_heap_size = INNER_HEAP_SIZE;
|
size_t nx_inner_heap_size = INNER_HEAP_SIZE;
|
||||||
char nx_inner_heap[INNER_HEAP_SIZE];
|
char nx_inner_heap[INNER_HEAP_SIZE];
|
||||||
|
|
||||||
|
@ -33,6 +33,9 @@ extern "C" {
|
||||||
alignas(16) u8 __nx_exception_stack[ams::os::MemoryPageSize];
|
alignas(16) u8 __nx_exception_stack[ams::os::MemoryPageSize];
|
||||||
u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
|
u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
|
||||||
void __libnx_exception_handler(ThreadExceptionDump *ctx);
|
void __libnx_exception_handler(ThreadExceptionDump *ctx);
|
||||||
|
|
||||||
|
void *__libnx_thread_alloc(size_t size);
|
||||||
|
void __libnx_thread_free(void *mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ams {
|
namespace ams {
|
||||||
|
@ -109,6 +112,26 @@ void __appExit(void) {
|
||||||
fsExit();
|
fsExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ams {
|
||||||
|
|
||||||
|
void *Malloc(size_t size) {
|
||||||
|
AMS_ABORT("ams::Malloc was called");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Free(void *ptr) {
|
||||||
|
AMS_ABORT("ams::Free 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");
|
||||||
|
}
|
||||||
|
|
||||||
void *operator new(size_t size) {
|
void *operator new(size_t size) {
|
||||||
return Allocate(size);
|
return Allocate(size);
|
||||||
}
|
}
|
||||||
|
@ -153,32 +176,30 @@ namespace {
|
||||||
|
|
||||||
class ContentManagerServerManager : public sf::hipc::ServerManager<ContentManagerNumServers, ContentManagerServerOptions, ContentManagerMaxSessions> {
|
class ContentManagerServerManager : public sf::hipc::ServerManager<ContentManagerNumServers, ContentManagerServerOptions, ContentManagerMaxSessions> {
|
||||||
private:
|
private:
|
||||||
using Interface = ncm::IContentManager;
|
|
||||||
using ServiceImpl = ncm::ContentManagerImpl;
|
using ServiceImpl = ncm::ContentManagerImpl;
|
||||||
private:
|
private:
|
||||||
os::ThreadType thread;
|
os::ThreadType m_thread;
|
||||||
std::shared_ptr<Interface> ncm_manager;
|
sf::SharedPointer<ncm::IContentManager> m_manager;
|
||||||
private:
|
private:
|
||||||
static void ThreadFunction(void *_this) {
|
static void ThreadFunction(void *_this) {
|
||||||
reinterpret_cast<ContentManagerServerManager *>(_this)->LoopProcess();
|
reinterpret_cast<ContentManagerServerManager *>(_this)->LoopProcess();
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
ContentManagerServerManager() : ncm_manager() { /* ... */ }
|
explicit ContentManagerServerManager(sf::SharedPointer<ncm::IContentManager> manager) : m_manager(manager) { /* ... */ }
|
||||||
|
|
||||||
ams::Result Initialize(std::shared_ptr<Interface> manager_obj) {
|
ams::Result Initialize() {
|
||||||
this->ncm_manager = manager_obj;
|
return this->RegisterObjectForServer(m_manager, ContentManagerServiceName, ContentManagerManagerSessions);
|
||||||
return this->RegisterServer<Interface, ServiceImpl>(ContentManagerServiceName, ContentManagerManagerSessions, this->ncm_manager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ams::Result StartThreads() {
|
ams::Result StartThreads() {
|
||||||
R_TRY(os::CreateThread(std::addressof(this->thread), ThreadFunction, this, g_content_manager_thread_stack, sizeof(g_content_manager_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(ncm, ContentManagerServerIpcSession)));
|
R_TRY(os::CreateThread(std::addressof(m_thread), ThreadFunction, this, g_content_manager_thread_stack, sizeof(g_content_manager_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(ncm, ContentManagerServerIpcSession)));
|
||||||
os::SetThreadNamePointer(std::addressof(this->thread), AMS_GET_SYSTEM_THREAD_NAME(ncm, ContentManagerServerIpcSession));
|
os::SetThreadNamePointer(std::addressof(m_thread), AMS_GET_SYSTEM_THREAD_NAME(ncm, ContentManagerServerIpcSession));
|
||||||
os::StartThread(std::addressof(this->thread));
|
os::StartThread(std::addressof(m_thread));
|
||||||
return ResultSuccess();
|
return ResultSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wait() {
|
void Wait() {
|
||||||
os::WaitThread(std::addressof(this->thread));
|
os::WaitThread(std::addressof(m_thread));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -197,39 +218,38 @@ namespace {
|
||||||
|
|
||||||
class LocationResolverServerManager : public sf::hipc::ServerManager<LocationResolverNumServers, LocationResolverServerOptions, LocationResolverMaxSessions> {
|
class LocationResolverServerManager : public sf::hipc::ServerManager<LocationResolverNumServers, LocationResolverServerOptions, LocationResolverMaxSessions> {
|
||||||
private:
|
private:
|
||||||
using Interface = lr::ILocationResolverManager;
|
|
||||||
using ServiceImpl = lr::LocationResolverManagerImpl;
|
using ServiceImpl = lr::LocationResolverManagerImpl;
|
||||||
private:
|
private:
|
||||||
os::ThreadType thread;
|
os::ThreadType m_thread;
|
||||||
std::shared_ptr<Interface> lr_manager;
|
sf::SharedPointer<lr::ILocationResolverManager> m_manager;
|
||||||
private:
|
private:
|
||||||
static void ThreadFunction(void *_this) {
|
static void ThreadFunction(void *_this) {
|
||||||
reinterpret_cast<LocationResolverServerManager *>(_this)->LoopProcess();
|
reinterpret_cast<LocationResolverServerManager *>(_this)->LoopProcess();
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
LocationResolverServerManager(ServiceImpl &m) : lr_manager(sf::GetSharedPointerTo<Interface>(m)) { /* ... */ }
|
LocationResolverServerManager(sf::SharedPointer<lr::ILocationResolverManager> manager) : m_manager(manager) { /* ... */ }
|
||||||
|
|
||||||
ams::Result Initialize() {
|
ams::Result Initialize() {
|
||||||
return this->RegisterServer<Interface, ServiceImpl>(LocationResolverServiceName, LocationResolverManagerSessions, this->lr_manager);
|
return this->RegisterObjectForServer(m_manager, LocationResolverServiceName, LocationResolverManagerSessions);
|
||||||
}
|
}
|
||||||
|
|
||||||
ams::Result StartThreads() {
|
ams::Result StartThreads() {
|
||||||
R_TRY(os::CreateThread(std::addressof(this->thread), ThreadFunction, this, g_location_resolver_thread_stack, sizeof(g_location_resolver_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(ncm, LocationResolverServerIpcSession)));
|
R_TRY(os::CreateThread(std::addressof(m_thread), ThreadFunction, this, g_location_resolver_thread_stack, sizeof(g_location_resolver_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(ncm, LocationResolverServerIpcSession)));
|
||||||
os::SetThreadNamePointer(std::addressof(this->thread), AMS_GET_SYSTEM_THREAD_NAME(ncm, LocationResolverServerIpcSession));
|
os::SetThreadNamePointer(std::addressof(m_thread), AMS_GET_SYSTEM_THREAD_NAME(ncm, LocationResolverServerIpcSession));
|
||||||
os::StartThread(std::addressof(this->thread));
|
os::StartThread(std::addressof(m_thread));
|
||||||
return ResultSuccess();
|
return ResultSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wait() {
|
void Wait() {
|
||||||
os::WaitThread(std::addressof(this->thread));
|
os::WaitThread(std::addressof(m_thread));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ncm::ContentManagerImpl g_ncm_manager_service_object;
|
sf::UnmanagedServiceObject<ncm::IContentManager, ncm::ContentManagerImpl> g_ncm_manager_service_object;
|
||||||
ContentManagerServerManager g_ncm_server_manager;
|
ContentManagerServerManager g_ncm_server_manager(g_ncm_manager_service_object.GetShared());
|
||||||
|
|
||||||
lr::LocationResolverManagerImpl g_lr_manager_service_object;
|
sf::UnmanagedServiceObject<lr::ILocationResolverManager, lr::LocationResolverManagerImpl> g_lr_manager_service_object;
|
||||||
LocationResolverServerManager g_lr_server_manager(g_lr_manager_service_object);
|
LocationResolverServerManager g_lr_server_manager(g_lr_manager_service_object.GetShared());
|
||||||
|
|
||||||
/* Compile-time configuration. */
|
/* Compile-time configuration. */
|
||||||
#ifdef NCM_BUILD_FOR_INTITIALIZE
|
#ifdef NCM_BUILD_FOR_INTITIALIZE
|
||||||
|
@ -260,15 +280,14 @@ int main(int argc, char **argv)
|
||||||
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(ncm, MainWaitThreads));
|
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(ncm, MainWaitThreads));
|
||||||
|
|
||||||
/* Create and initialize the content manager. */
|
/* Create and initialize the content manager. */
|
||||||
auto content_manager = sf::GetSharedPointerTo<ncm::IContentManager>(g_ncm_manager_service_object);
|
R_ABORT_UNLESS(g_ncm_manager_service_object.GetImpl().Initialize(ManagerConfig));
|
||||||
R_ABORT_UNLESS(content_manager->GetImpl().Initialize(ManagerConfig));
|
|
||||||
|
|
||||||
/* Initialize ncm's server and start threads. */
|
/* Initialize ncm's server and start threads. */
|
||||||
R_ABORT_UNLESS(g_ncm_server_manager.Initialize(content_manager));
|
R_ABORT_UNLESS(g_ncm_server_manager.Initialize());
|
||||||
R_ABORT_UNLESS(g_ncm_server_manager.StartThreads());
|
R_ABORT_UNLESS(g_ncm_server_manager.StartThreads());
|
||||||
|
|
||||||
/* Initialize ncm api. */
|
/* Initialize ncm api. */
|
||||||
ncm::InitializeWithObject(content_manager);
|
ncm::InitializeWithObject(g_ncm_manager_service_object.GetShared());
|
||||||
|
|
||||||
/* Initialize lr's server and start threads. */
|
/* Initialize lr's server and start threads. */
|
||||||
R_ABORT_UNLESS(g_lr_server_manager.Initialize());
|
R_ABORT_UNLESS(g_lr_server_manager.Initialize());
|
||||||
|
|
Loading…
Reference in a new issue