From 61cbb0f86ec008a3dd9e5bebe6b538fd04f46429 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 21 Apr 2018 21:40:26 -0600 Subject: [PATCH] Stratosphere: Implement sm:->Initialize() --- stratosphere/sm/source/sm_main.cpp | 10 ++++++++-- stratosphere/sm/source/sm_user_service.cpp | 4 ++-- stratosphere/sm/source/sm_user_service.hpp | 5 +++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/stratosphere/sm/source/sm_main.cpp b/stratosphere/sm/source/sm_main.cpp index be1e1555f..eaa47001a 100644 --- a/stratosphere/sm/source/sm_main.cpp +++ b/stratosphere/sm/source/sm_main.cpp @@ -41,7 +41,8 @@ void __appInit(void) { } void __appExit(void) { - /* Nothing to clean up, because we're sm. */ + /* Disconnect from ourselves. */ + smExit(); } int main(int argc, char **argv) @@ -51,8 +52,13 @@ int main(int argc, char **argv) /* TODO: What's a good timeout value to use here? */ WaitableManager *server_manager = new WaitableManager(U64_MAX); - /* Add services to manager. */ + /* Create sm:, (and thus allow things to register to it). */ server_manager->add_waitable(new ManagedPortServer("sm:", 0x40)); + + /* Initialize, connecting to ourself. */ + smInitialize(); + + /* Create sm:m, using libnx to talk to ourself. */ server_manager->add_waitable(new ServiceServer("sm:m", 1)); /* Loop forever, servicing our services. */ diff --git a/stratosphere/sm/source/sm_user_service.cpp b/stratosphere/sm/source/sm_user_service.cpp index d11ea908f..aed18d948 100644 --- a/stratosphere/sm/source/sm_user_service.cpp +++ b/stratosphere/sm/source/sm_user_service.cpp @@ -25,8 +25,8 @@ Result UserService::dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, std::tuple UserService::initialize(PidDescriptor pid) { - /* TODO */ - return std::make_tuple(0xF601); + this->pid = pid.pid; + return std::make_tuple(0); } std::tuple UserService::get_service(u64 service) { diff --git a/stratosphere/sm/source/sm_user_service.hpp b/stratosphere/sm/source/sm_user_service.hpp index df13f25da..f01d14acd 100644 --- a/stratosphere/sm/source/sm_user_service.hpp +++ b/stratosphere/sm/source/sm_user_service.hpp @@ -10,8 +10,13 @@ enum UserServiceCmd { }; class UserService : IServiceObject { + u64 pid; + public: Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); + UserService() { + this->pid = U64_MAX; + } private: /* Actual commands. */