mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-24 19:54:22 -04:00
sm, spl: update to use new sf semantics
This commit is contained in:
parent
f06de12bea
commit
21236020cb
7 changed files with 134 additions and 31 deletions
|
@ -25,7 +25,7 @@ extern "C" {
|
|||
|
||||
u32 __nx_applet_type = AppletType_None;
|
||||
|
||||
#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];
|
||||
|
||||
|
@ -83,9 +83,37 @@ void __appExit(void) {
|
|||
|
||||
namespace {
|
||||
|
||||
/* sm:m, sm:, sm:dmnt. */
|
||||
constexpr size_t NumServers = 3;
|
||||
sf::hipc::ServerManager<NumServers> g_server_manager;
|
||||
enum PortIndex {
|
||||
PortIndex_User,
|
||||
PortIndex_Manager,
|
||||
PortIndex_DebugMonitor,
|
||||
PortIndex_Count,
|
||||
};
|
||||
|
||||
class ServerManager final : public sf::hipc::ServerManager<PortIndex_Count> {
|
||||
private:
|
||||
virtual ams::Result OnNeedsToAccept(int port_index, Server *server) override;
|
||||
};
|
||||
|
||||
using Allocator = sf::ExpHeapAllocator;
|
||||
using ObjectFactory = sf::ObjectFactory<sf::ExpHeapAllocator::Policy>;
|
||||
|
||||
alignas(0x40) constinit u8 g_server_allocator_buffer[8_KB];
|
||||
Allocator g_server_allocator;
|
||||
|
||||
ServerManager g_server_manager;
|
||||
|
||||
ams::Result ServerManager::OnNeedsToAccept(int port_index, Server *server) {
|
||||
switch (port_index) {
|
||||
case PortIndex_User:
|
||||
return this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced<sm::impl::IUserInterface, sm::UserService>(std::addressof(g_server_allocator)));
|
||||
case PortIndex_Manager:
|
||||
return this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced<sm::impl::IManagerInterface, sm::ManagerService>(std::addressof(g_server_allocator)));
|
||||
case PortIndex_DebugMonitor:
|
||||
return this->AcceptImpl(server, ObjectFactory::CreateSharedEmplaced<sm::impl::IDebugMonitorInterface, sm::DebugMonitorService>(std::addressof(g_server_allocator)));
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
}
|
||||
|
||||
ams::Result ResumeImpl(os::WaitableHolderType *session_holder) {
|
||||
return g_server_manager.Process(session_holder);
|
||||
|
@ -93,24 +121,35 @@ namespace {
|
|||
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Set thread name. */
|
||||
os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(sm, Main));
|
||||
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(sm, Main));
|
||||
|
||||
/* Setup server allocator. */
|
||||
g_server_allocator.Attach(lmem::CreateExpHeap(g_server_allocator_buffer, sizeof(g_server_allocator_buffer), lmem::CreateOption_None));
|
||||
|
||||
/* Create sm:, (and thus allow things to register to it). */
|
||||
{
|
||||
Handle sm_h;
|
||||
R_ABORT_UNLESS(svc::ManageNamedPort(&sm_h, "sm:", 0x40));
|
||||
g_server_manager.RegisterServer<sm::impl::IUserInterface, sm::UserService>(sm_h);
|
||||
g_server_manager.RegisterServer(PortIndex_User, sm_h);
|
||||
}
|
||||
|
||||
/* Create sm:m manually. */
|
||||
{
|
||||
Handle smm_h;
|
||||
R_ABORT_UNLESS(sm::impl::RegisterServiceForSelf(&smm_h, sm::ServiceName::Encode("sm:m"), 1));
|
||||
g_server_manager.RegisterServer<sm::impl::IManagerInterface, sm::ManagerService>(smm_h);
|
||||
g_server_manager.RegisterServer(PortIndex_Manager, smm_h);
|
||||
sm::impl::TestAndResume(ResumeImpl);
|
||||
}
|
||||
|
||||
|
@ -119,7 +158,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
Handle smdmnt_h;
|
||||
R_ABORT_UNLESS(sm::impl::RegisterServiceForSelf(&smdmnt_h, sm::ServiceName::Encode("sm:dmnt"), 1));
|
||||
g_server_manager.RegisterServer<sm::impl::IDebugMonitorInterface, sm::DebugMonitorService>(smdmnt_h);
|
||||
g_server_manager.RegisterServer(PortIndex_DebugMonitor, smdmnt_h);
|
||||
sm::impl::TestAndResume(ResumeImpl);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue