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. */