ams_mitm: update for new sf semantics

This commit is contained in:
Michael Scire
2021-01-19 02:34:02 -08:00
parent 88a99bc68e
commit 3b2c2ba5a2
36 changed files with 293 additions and 489 deletions

View File

@@ -21,6 +21,11 @@ namespace ams::mitm::fs {
namespace {
enum PortIndex {
PortIndex_Mitm,
PortIndex_Count,
};
constexpr sm::ServiceName MitmServiceName = sm::ServiceName::Encode("fsp-srv");
struct ServerOptions {
@@ -29,10 +34,27 @@ namespace ams::mitm::fs {
static constexpr size_t MaxDomainObjects = 0x4000;
};
constexpr size_t MaxServers = 1;
constexpr size_t MaxSessions = 61;
sf::hipc::ServerManager<MaxServers, ServerOptions, MaxSessions> g_server_manager;
class ServerManager final : public sf::hipc::ServerManager<PortIndex_Count, ServerOptions, MaxSessions> {
private:
virtual Result OnNeedsToAccept(int port_index, Server *server) override;
};
ServerManager g_server_manager;
Result ServerManager::OnNeedsToAccept(int port_index, Server *server) {
/* Acknowledge the mitm session. */
std::shared_ptr<::Service> fsrv;
sm::MitmProcessInfo client_info;
server->AcknowledgeMitmSession(std::addressof(fsrv), std::addressof(client_info));
switch (port_index) {
case PortIndex_Mitm:
return this->AcceptMitmImpl(server, sf::CreateSharedObjectEmplaced<IFsMitmInterface, FsMitmService>(decltype(fsrv)(fsrv), client_info), fsrv);
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
constexpr size_t TotalThreads = 5;
static_assert(TotalThreads >= 1, "TotalThreads");
@@ -78,7 +100,7 @@ namespace ams::mitm::fs {
void MitmModule::ThreadFunction(void *arg) {
/* Create fs mitm. */
R_ABORT_UNLESS((g_server_manager.RegisterMitmServer<IFsMitmInterface, FsMitmService>(MitmServiceName)));
R_ABORT_UNLESS((g_server_manager.RegisterMitmServer<FsMitmService>(PortIndex_Mitm, MitmServiceName)));
/* Process for the server. */
ProcessForServerOnAllThreads();