From 581d3de04f60f024c1cf4779ac6339be03894f7e Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sun, 10 Jun 2018 03:06:50 -0600 Subject: [PATCH] fs.mitm: Get Title ID on fsp-srv init, Add worker to handle subinterfaces. --- include/stratosphere.hpp | 1 + include/stratosphere/childholder.hpp | 76 ++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 include/stratosphere/childholder.hpp diff --git a/include/stratosphere.hpp b/include/stratosphere.hpp index 0b627440..67b73b83 100644 --- a/include/stratosphere.hpp +++ b/include/stratosphere.hpp @@ -7,6 +7,7 @@ #include "stratosphere/serviceserver.hpp" #include "stratosphere/managedportserver.hpp" #include "stratosphere/existingportserver.hpp" +#include "stratosphere/childholder.hpp" #include "stratosphere/ievent.hpp" #include "stratosphere/systemevent.hpp" diff --git a/include/stratosphere/childholder.hpp b/include/stratosphere/childholder.hpp new file mode 100644 index 00000000..428ccef6 --- /dev/null +++ b/include/stratosphere/childholder.hpp @@ -0,0 +1,76 @@ +#pragma once +#include +#include + +#include "iwaitable.hpp" + +class ChildWaitableHolder : public IWaitable { + protected: + std::vector children; + + public: + /* Implicit constructor. */ + + void add_child(IWaitable *child) { + this->children.push_back(child); + } + + virtual ~ChildWaitableHolder() { + for (unsigned int i = 0; i < this->children.size(); i++) { + delete this->children[i]; + } + this->children.clear(); + } + + /* IWaitable */ + virtual unsigned int get_num_waitables() { + unsigned int n = 0; + for (unsigned int i = 0; i < this->children.size(); i++) { + if (this->children[i]) { + n += this->children[i]->get_num_waitables(); + } + } + return n; + } + + virtual void get_waitables(IWaitable **dst) { + unsigned int n = 0; + for (unsigned int i = 0; i < this->children.size(); i++) { + if (this->children[i]) { + this->children[i]->get_waitables(&dst[n]); + n += this->children[i]->get_num_waitables(); + } + } + } + + virtual void delete_child(IWaitable *child) { + unsigned int i; + for (i = 0; i < this->children.size(); i++) { + if (this->children[i] == child) { + break; + } + } + + if (i == this->children.size()) { + /* TODO: Panic, because this isn't our child. */ + } else { + delete this->children[i]; + this->children.erase(this->children.begin() + i); + } + } + + virtual Handle get_handle() { + /* We don't have a handle. */ + return 0; + } + + + virtual void handle_deferred() { + /* TODO: Panic, because we can never defer a server. */ + } + + virtual Result handle_signaled(u64 timeout) { + /* TODO: Panic, because we can never be signalled. */ + return 0; + } +}; \ No newline at end of file