htc: hook up creation of the htc manager service object

This commit is contained in:
Michael Scire
2021-02-09 05:37:54 -08:00
committed by SciresM
parent 4408ad6a47
commit 889f144b27
12 changed files with 418 additions and 5 deletions

View File

@@ -0,0 +1,102 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "htc_htc_service_object.hpp"
namespace ams::htc::server {
HtcServiceObject::HtcServiceObject(htclow::HtclowManager *htclow_manager) {
AMS_ABORT("HtcServiceObject::HtcServiceObject");
}
HtcmiscImpl *HtcServiceObject::GetHtcmiscImpl() {
AMS_ABORT("HtcServiceObject::GetHtcmiscImpl");
}
Result HtcServiceObject::GetEnvironmentVariable(sf::Out<s32> out_size, const sf::OutBuffer &out, const sf::InBuffer &name) {
AMS_ABORT("HtcServiceObject::GetEnvironmentVariable");
}
Result HtcServiceObject::GetEnvironmentVariableLength(sf::Out<s32> out_size, const sf::InBuffer &name) {
AMS_ABORT("HtcServiceObject::GetEnvironmentVariableLength");
}
Result HtcServiceObject::GetHostConnectionEvent(sf::OutCopyHandle out) {
AMS_ABORT("HtcServiceObject::GetHostConnectionEvent");
}
Result HtcServiceObject::GetHostDisconnectionEvent(sf::OutCopyHandle out) {
AMS_ABORT("HtcServiceObject::GetHostDisconnectionEvent");
}
Result HtcServiceObject::GetHostConnectionEventForSystem(sf::OutCopyHandle out) {
AMS_ABORT("HtcServiceObject::GetHostConnectionEventForSystem");
}
Result HtcServiceObject::GetHostDisconnectionEventForSystem(sf::OutCopyHandle out) {
AMS_ABORT("HtcServiceObject::GetHostDisconnectionEventForSystem");
}
Result HtcServiceObject::GetBridgeIpAddress(const sf::OutBuffer &out) {
AMS_ABORT("HtcServiceObject::GetBridgeIpAddress");
}
Result HtcServiceObject::GetBridgePort(const sf::OutBuffer &out) {
AMS_ABORT("HtcServiceObject::GetBridgePort");
}
Result HtcServiceObject::SetCradleAttached(bool attached) {
AMS_ABORT("HtcServiceObject::SetCradleAttached");
}
Result HtcServiceObject::GetBridgeSubnetMask(const sf::OutBuffer &out) {
AMS_ABORT("HtcServiceObject::GetBridgeSubnetMask");
}
Result HtcServiceObject::GetBridgeMacAddress(const sf::OutBuffer &out) {
AMS_ABORT("HtcServiceObject::GetBridgeMacAddress");
}
Result HtcServiceObject::GetWorkingDirectoryPath(const sf::OutBuffer &out, s32 max_len) {
AMS_ABORT("HtcServiceObject::GetWorkingDirectoryPath");
}
Result HtcServiceObject::GetWorkingDirectoryPathSize(sf::Out<s32> out_size) {
AMS_ABORT("HtcServiceObject::GetWorkingDirectoryPathSize");
}
Result HtcServiceObject::RunOnHostStart(sf::Out<u32> out_id, sf::OutCopyHandle out, const sf::InBuffer &args) {
AMS_ABORT("HtcServiceObject::RunOnHostStart");
}
Result HtcServiceObject::RunOnHostResults(sf::Out<s32> out_result, u32 id) {
AMS_ABORT("HtcServiceObject::RunOnHostResults");
}
Result HtcServiceObject::SetBridgeIpAddress(const sf::InBuffer &arg) {
AMS_ABORT("HtcServiceObject::SetBridgeIpAddress");
}
Result HtcServiceObject::SetBridgeSubnetMask(const sf::InBuffer &arg) {
AMS_ABORT("HtcServiceObject::SetBridgeSubnetMask");
}
Result HtcServiceObject::SetBridgePort(const sf::InBuffer &arg) {
AMS_ABORT("HtcServiceObject::SetBridgePort");
}
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "../../htclow/htclow_manager.hpp"
namespace ams::htc::server {
class HtcServiceObject {
private:
/* TODO */
public:
HtcServiceObject(htclow::HtclowManager *htclow_manager);
public:
HtcmiscImpl *GetHtcmiscImpl();
public:
Result GetEnvironmentVariable(sf::Out<s32> out_size, const sf::OutBuffer &out, const sf::InBuffer &name);
Result GetEnvironmentVariableLength(sf::Out<s32> out_size, const sf::InBuffer &name);
Result GetHostConnectionEvent(sf::OutCopyHandle out);
Result GetHostDisconnectionEvent(sf::OutCopyHandle out);
Result GetHostConnectionEventForSystem(sf::OutCopyHandle out);
Result GetHostDisconnectionEventForSystem(sf::OutCopyHandle out);
Result GetBridgeIpAddress(const sf::OutBuffer &out);
Result GetBridgePort(const sf::OutBuffer &out);
Result SetCradleAttached(bool attached);
Result GetBridgeSubnetMask(const sf::OutBuffer &out);
Result GetBridgeMacAddress(const sf::OutBuffer &out);
Result GetWorkingDirectoryPath(const sf::OutBuffer &out, s32 max_len);
Result GetWorkingDirectoryPathSize(sf::Out<s32> out_size);
Result RunOnHostStart(sf::Out<u32> out_id, sf::OutCopyHandle out, const sf::InBuffer &args);
Result RunOnHostResults(sf::Out<s32> out_result, u32 id);
Result SetBridgeIpAddress(const sf::InBuffer &arg);
Result SetBridgeSubnetMask(const sf::InBuffer &arg);
Result SetBridgePort(const sf::InBuffer &arg);
};
static_assert(tma::IsIHtcManager<HtcServiceObject>);
}

View File

@@ -0,0 +1,89 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "htc_htc_service_object.hpp"
#include "htc_htcmisc_manager.hpp"
namespace ams::htc::server {
namespace {
static constexpr inline size_t NumServers = 1;
static constexpr inline size_t MaxSessions = 30;
static constexpr inline sm::ServiceName ServiceName = sm::ServiceName::Encode("htc");
using ServerOptions = sf::hipc::DefaultServerManagerOptions;
using ServerManager = sf::hipc::ServerManager<NumServers, ServerOptions, MaxSessions>;
constinit TYPED_STORAGE(ServerManager) g_server_manager_storage;
constinit ServerManager *g_server_manager = nullptr;
constinit HtcmiscImpl *g_misc_impl = nullptr;
}
void InitializeHtcmiscServer(htclow::HtclowManager *htclow_manager) {
/* Check that we haven't already initialized. */
AMS_ASSERT(g_server_manager == nullptr);
/* Create the server manager. */
std::construct_at(GetPointer(g_server_manager_storage));
/* Set the server manager pointer. */
g_server_manager = GetPointer(g_server_manager_storage);
/* Create and register the htc manager object. */
HtcServiceObject *service_object;
R_ABORT_UNLESS(g_server_manager->RegisterObjectForServer(CreateHtcmiscManager(std::addressof(service_object), htclow_manager), ServiceName, MaxSessions));
/* Set the misc impl. */
g_misc_impl = service_object->GetHtcmiscImpl();
/* Start the server. */
g_server_manager->ResumeProcessing();
}
void FinalizeHtcmiscServer() {
/* Check that we've already initialized. */
AMS_ASSERT(g_server_manager != nullptr);
/* Clear the misc impl. */
g_misc_impl = nullptr;
/* Clear and destroy. */
std::destroy_at(g_server_manager);
g_server_manager = nullptr;
}
void LoopHtcmiscServer() {
/* Check that we've already initialized. */
AMS_ASSERT(g_server_manager != nullptr);
g_server_manager->LoopProcess();
}
void RequestStopHtcmiscServer() {
/* Check that we've already initialized. */
AMS_ASSERT(g_server_manager != nullptr);
g_server_manager->RequestStopProcessing();
}
HtcmiscImpl *GetHtcmiscImpl() {
return g_misc_impl;
}
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "htc_htcmisc_manager.hpp"
namespace ams::htc::server {
namespace {
mem::StandardAllocator g_allocator;
sf::StandardAllocatorMemoryResource g_sf_resource(std::addressof(g_allocator));
alignas(os::MemoryPageSize) constinit u8 g_heap[util::AlignUp(sizeof(HtcServiceObject), os::MemoryPageSize) + 12_KB];
class StaticAllocatorInitializer {
public:
StaticAllocatorInitializer() {
g_allocator.Initialize(g_heap, sizeof(g_heap));
}
} g_static_allocator_initializer;
using ObjectFactory = sf::ObjectFactory<sf::MemoryResourceAllocationPolicy>;
}
sf::SharedPointer<tma::IHtcManager> CreateHtcmiscManager(HtcServiceObject **out, htclow::HtclowManager *htclow_manager) {
auto obj = ObjectFactory::CreateSharedEmplaced<tma::IHtcManager, HtcServiceObject>(std::addressof(g_sf_resource), htclow_manager);
*out = std::addressof(obj.GetImpl());
return obj;
}
}

View File

@@ -0,0 +1,24 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "htc_htc_service_object.hpp"
namespace ams::htc::server {
sf::SharedPointer<tma::IHtcManager> CreateHtcmiscManager(HtcServiceObject **out, htclow::HtclowManager *htclow_manager);
}

View File

@@ -52,8 +52,12 @@ namespace ams::htclow {
return ResultSuccess();
}
//void HtclowManagerImpl::CloseDriver();
//
//void HtclowManagerImpl::Disconnect();
void HtclowManagerImpl::CloseDriver() {
AMS_ABORT("HtclowManagerImpl::CloseDriver");
}
void HtclowManagerImpl::Disconnect() {
AMS_ABORT("HtclowManagerImpl::Disconnect");
}
}