1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-18 00:12:03 +00:00

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

@ -82,6 +82,7 @@
#include <stratosphere/socket.hpp> #include <stratosphere/socket.hpp>
#include <stratosphere/spl.hpp> #include <stratosphere/spl.hpp>
#include <stratosphere/time.hpp> #include <stratosphere/time.hpp>
#include <stratosphere/tma.hpp>
#include <stratosphere/updater.hpp> #include <stratosphere/updater.hpp>
#include <stratosphere/usb.hpp> #include <stratosphere/usb.hpp>
#include <stratosphere/wec.hpp> #include <stratosphere/wec.hpp>

View file

@ -15,3 +15,4 @@
*/ */
#pragma once #pragma once
#include <stratosphere/htc/server/htc_htcmisc_hipc_server.hpp>

View file

@ -0,0 +1,35 @@
/*
* 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 <vapours.hpp>
namespace ams::htclow {
class HtclowManager;
}
namespace ams::htc::server {
void InitializeHtcmiscServer(htclow::HtclowManager *htclow_manager);
void FinalizeHtcmiscServer();
void LoopHtcmiscServer();
void RequestStopHtcmiscServer();
class HtcmiscImpl;
HtcmiscImpl *GetHtcmiscImpl();
}

View file

@ -0,0 +1,18 @@
/*
* 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/tma/tma_i_htc_manager.hpp>

View file

@ -0,0 +1,41 @@
/*
* 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 <vapours.hpp>
/* NOTE: Minimum firmware version not enforced for any commands. */
#define AMS_TMA_I_HTC_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetEnvironmentVariable, (sf::Out<s32> out_size, const sf::OutBuffer &out, const sf::InBuffer &name), (out_size, out, name)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetEnvironmentVariableLength, (sf::Out<s32> out_size, const sf::InBuffer &name), (out_size, name)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, GetHostConnectionEvent, (sf::OutCopyHandle out), (out)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetHostDisconnectionEvent, (sf::OutCopyHandle out), (out)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetHostConnectionEventForSystem, (sf::OutCopyHandle out), (out)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetHostDisconnectionEventForSystem, (sf::OutCopyHandle out), (out)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, GetBridgeIpAddress, (const sf::OutBuffer &out), (out)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, GetBridgePort, (const sf::OutBuffer &out), (out)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, SetCradleAttached, (bool attached), (attached)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, GetBridgeSubnetMask, (const sf::OutBuffer &out), (out)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, GetBridgeMacAddress, (const sf::OutBuffer &out), (out)) \
AMS_SF_METHOD_INFO(C, H, 11, Result, GetWorkingDirectoryPath, (const sf::OutBuffer &out, s32 max_len), (out, max_len)) \
AMS_SF_METHOD_INFO(C, H, 12, Result, GetWorkingDirectoryPathSize, (sf::Out<s32> out_size), (out_size)) \
AMS_SF_METHOD_INFO(C, H, 13, Result, RunOnHostStart, (sf::Out<u32> out_id, sf::OutCopyHandle out, const sf::InBuffer &args), (out_id, out, args)) \
AMS_SF_METHOD_INFO(C, H, 14, Result, RunOnHostResults, (sf::Out<s32> out_result, u32 id), (out_result, id)) \
AMS_SF_METHOD_INFO(C, H, 15, Result, SetBridgeIpAddress, (const sf::InBuffer &arg), (arg)) \
AMS_SF_METHOD_INFO(C, H, 16, Result, SetBridgeSubnetMask, (const sf::InBuffer &arg), (arg)) \
AMS_SF_METHOD_INFO(C, H, 17, Result, SetBridgePort, (const sf::InBuffer &arg), (arg))
AMS_SF_DEFINE_INTERFACE(ams::tma, IHtcManager, AMS_TMA_I_HTC_MANAGER_INTERFACE_INFO)

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(); return ResultSuccess();
} }
//void HtclowManagerImpl::CloseDriver(); void HtclowManagerImpl::CloseDriver() {
// AMS_ABORT("HtclowManagerImpl::CloseDriver");
//void HtclowManagerImpl::Disconnect(); }
void HtclowManagerImpl::Disconnect() {
AMS_ABORT("HtclowManagerImpl::Disconnect");
}
} }

View file

@ -185,7 +185,7 @@ namespace ams::htc {
} }
void HtcIpcThreadFunction(void *arg) { void HtcIpcThreadFunction(void *arg) {
//htc::server::LoopHtcmiscServer(); htc::server::LoopHtcmiscServer();
} }
void HtcfsIpcThreadFunction(void *arg) { void HtcfsIpcThreadFunction(void *arg) {
@ -218,7 +218,7 @@ int main(int argc, char **argv)
auto *htclow_manager = htclow::HtclowManagerHolder::GetHtclowManager(); auto *htclow_manager = htclow::HtclowManagerHolder::GetHtclowManager();
/* Initialize the htc misc server. */ /* Initialize the htc misc server. */
//htc::server::InitializeHtcmiscServer(htclow_manager); htc::server::InitializeHtcmiscServer(htclow_manager);
/* Create the htc misc ipc thread. */ /* Create the htc misc ipc thread. */
os::ThreadType htc_ipc_thread; os::ThreadType htc_ipc_thread;