Revert "hoc-clk: add live vdd2, live boost clock and basic pwm dimming"
This reverts commit 15b7df8ef1.
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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 "htcs_manager_service_object.hpp"
|
||||
|
||||
namespace ams::htcs::server {
|
||||
|
||||
namespace {
|
||||
|
||||
static constexpr inline size_t NumServers = 1;
|
||||
static constexpr inline size_t MaxSessions = 63;
|
||||
static constexpr inline sm::ServiceName ServiceName = sm::ServiceName::Encode("htcs");
|
||||
|
||||
struct ServerOptions {
|
||||
static constexpr size_t PointerBufferSize = 0x80;
|
||||
static constexpr size_t MaxDomains = 0x10;
|
||||
static constexpr size_t MaxDomainObjects = 100;
|
||||
static constexpr bool CanDeferInvokeRequest = false;
|
||||
static constexpr bool CanManageMitmServers = false;
|
||||
};
|
||||
|
||||
using ServerManager = sf::hipc::ServerManager<NumServers, ServerOptions, MaxSessions>;
|
||||
|
||||
/* Service object. */
|
||||
ServerManager g_server_manager;
|
||||
|
||||
/* Service object. */
|
||||
constinit sf::UnmanagedServiceObject<tma::IHtcsManager, ManagerServiceObject> g_htcs_service_object;
|
||||
|
||||
}
|
||||
|
||||
void Initialize() {
|
||||
/* Add a reference to the htcs manager. */
|
||||
htcs::impl::HtcsManagerHolder::AddReference();
|
||||
}
|
||||
|
||||
void RegisterHipcServer() {
|
||||
/* Register the service. */
|
||||
R_ABORT_UNLESS(g_server_manager.RegisterObjectForServer(g_htcs_service_object.GetShared(), ServiceName, MaxSessions));
|
||||
}
|
||||
|
||||
void LoopHipcServer() {
|
||||
/* Loop, servicing services. */
|
||||
g_server_manager.LoopProcess();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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 "htcs_manager_service_object.hpp"
|
||||
#include "htcs_socket_service_object.hpp"
|
||||
#include "htcs_service_object_allocator.hpp"
|
||||
#include "../impl/htcs_manager.hpp"
|
||||
#include "../impl/htcs_impl.hpp"
|
||||
|
||||
namespace ams::htcs::server {
|
||||
|
||||
namespace {
|
||||
|
||||
class StaticAllocatorInitializer {
|
||||
public:
|
||||
StaticAllocatorInitializer() {
|
||||
ServiceObjectAllocator::Initialize(lmem::CreateOption_ThreadSafe);
|
||||
}
|
||||
} g_static_allocator_initializer;
|
||||
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::GetPeerNameAny(sf::Out<htcs::HtcsPeerName> out) {
|
||||
*out = impl::GetPeerNameAny();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::GetDefaultHostName(sf::Out<htcs::HtcsPeerName> out) {
|
||||
*out = impl::GetDefaultHostName();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::CreateSocketOld(sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out) {
|
||||
R_RETURN(this->CreateSocket(out_err, out, false));
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::CreateSocket(sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, bool enable_disconnection_emulation) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Create a new socket. */
|
||||
s32 desc;
|
||||
manager->Socket(out_err.GetPointer(), std::addressof(desc), enable_disconnection_emulation);
|
||||
|
||||
/* If an error occurred, we're done. */
|
||||
R_SUCCEED_IF(*out_err != 0);
|
||||
|
||||
/* Create a new socket object. */
|
||||
*out = ServiceObjectFactory::CreateSharedEmplaced<tma::ISocket, SocketServiceObject>(this, desc);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::RegisterProcessId(const sf::ClientProcessId &client_pid) {
|
||||
/* NOTE: Nintendo does nothing here. */
|
||||
AMS_UNUSED(client_pid);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::MonitorManager(const sf::ClientProcessId &client_pid) {
|
||||
/* NOTE: Nintendo does nothing here. */
|
||||
AMS_UNUSED(client_pid);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::StartSelect(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InMapAliasArray<s32> &read_handles, const sf::InMapAliasArray<s32> &write_handles, const sf::InMapAliasArray<s32> &exception_handles, s64 tv_sec, s64 tv_usec) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Start the select. */
|
||||
os::NativeHandle event_handle;
|
||||
R_TRY(manager->StartSelect(out_task_id.GetPointer(), std::addressof(event_handle), read_handles.ToSpan(), write_handles.ToSpan(), exception_handles.ToSpan(), tv_sec, tv_usec));
|
||||
|
||||
/* Set the output event handle. */
|
||||
out_event.SetValue(event_handle, true);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::EndSelect(sf::Out<s32> out_err, sf::Out<s32> out_count, const sf::OutMapAliasArray<s32> &read_handles, const sf::OutMapAliasArray<s32> &write_handles, const sf::OutMapAliasArray<s32> &exception_handles, u32 task_id) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* End the select. */
|
||||
R_RETURN(manager->EndSelect(out_err.GetPointer(), out_count.GetPointer(), read_handles.ToSpan(), write_handles.ToSpan(), exception_handles.ToSpan(), task_id));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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>
|
||||
|
||||
namespace ams::htcs::server {
|
||||
|
||||
class ManagerServiceObject : public sf::ISharedObject {
|
||||
public:
|
||||
Result Socket(sf::Out<s32> out_err, sf::Out<s32> out_sock);
|
||||
Result Close(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc);
|
||||
Result Connect(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, const htcs::SockAddrHtcs &address);
|
||||
Result Bind(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, const htcs::SockAddrHtcs &address);
|
||||
Result Listen(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, s32 backlog_count);
|
||||
Result Accept(sf::Out<s32> out_err, sf::Out<s32> out_res, sf::Out<htcs::SockAddrHtcs> out_address, s32 desc);
|
||||
Result Recv(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutBuffer &buffer, s32 desc, s32 flags);
|
||||
Result Send(sf::Out<s32> out_err, sf::Out<s64> out_size, s32 desc, const sf::InBuffer &buffer, s32 flags);
|
||||
Result Shutdown(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, s32 how);
|
||||
Result Fcntl(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, s32 command, s32 value);
|
||||
Result GetPeerNameAny(sf::Out<htcs::HtcsPeerName> out);
|
||||
Result GetDefaultHostName(sf::Out<htcs::HtcsPeerName> out);
|
||||
Result CreateSocketOld(sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out);
|
||||
Result CreateSocket(sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, bool enable_disconnection_emulation);
|
||||
Result RegisterProcessId(const sf::ClientProcessId &client_pid);
|
||||
Result MonitorManager(const sf::ClientProcessId &client_pid);
|
||||
Result StartSelect(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InMapAliasArray<s32> &read_handles, const sf::InMapAliasArray<s32> &write_handles, const sf::InMapAliasArray<s32> &exception_handles, s64 tv_sec, s64 tv_usec);
|
||||
Result EndSelect(sf::Out<s32> out_err, sf::Out<s32> out_count, const sf::OutMapAliasArray<s32> &read_handles, const sf::OutMapAliasArray<s32> &write_handles, const sf::OutMapAliasArray<s32> &exception_handles, u32 task_id);
|
||||
};
|
||||
static_assert(tma::IsIHtcsManager<ManagerServiceObject>);
|
||||
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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 "htcs_manager_service_object.hpp"
|
||||
#include "htcs_socket_service_object.hpp"
|
||||
|
||||
namespace ams::htcs::server {
|
||||
|
||||
#define AMS_HTCS_MANAGER_DEPRECATED_API(...) ({ AMS_UNUSED(__VA_ARGS__); AMS_ABORT("Deprecated IHtcsManager API %s was called.\n", AMS_CURRENT_FUNCTION_NAME); })
|
||||
|
||||
Result ManagerServiceObject::Socket(sf::Out<s32> out_err, sf::Out<s32> out_sock) {
|
||||
/* NOTE: This is a deprecated API, and Nintendo aborts when it is called. */
|
||||
AMS_HTCS_MANAGER_DEPRECATED_API(out_err, out_sock);
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::Close(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc) {
|
||||
/* NOTE: This is a deprecated API, and Nintendo aborts when it is called. */
|
||||
AMS_HTCS_MANAGER_DEPRECATED_API(out_err, out_res, desc);
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::Connect(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, const htcs::SockAddrHtcs &address) {
|
||||
/* NOTE: This is a deprecated API, and Nintendo aborts when it is called. */
|
||||
AMS_HTCS_MANAGER_DEPRECATED_API(out_err, out_res, desc, address);
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::Bind(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, const htcs::SockAddrHtcs &address) {
|
||||
/* NOTE: This is a deprecated API, and Nintendo aborts when it is called. */
|
||||
AMS_HTCS_MANAGER_DEPRECATED_API(out_err, out_res, desc, address);
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::Listen(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, s32 backlog_count) {
|
||||
/* NOTE: This is a deprecated API, and Nintendo aborts when it is called. */
|
||||
AMS_HTCS_MANAGER_DEPRECATED_API(out_err, out_res, desc, backlog_count);
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::Accept(sf::Out<s32> out_err, sf::Out<s32> out_res, sf::Out<htcs::SockAddrHtcs> out_address, s32 desc) {
|
||||
/* NOTE: This is a deprecated API, and Nintendo aborts when it is called. */
|
||||
AMS_HTCS_MANAGER_DEPRECATED_API(out_err, out_res, out_address, desc);
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::Recv(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutBuffer &buffer, s32 desc, s32 flags) {
|
||||
/* NOTE: This is a deprecated API, and Nintendo aborts when it is called. */
|
||||
AMS_HTCS_MANAGER_DEPRECATED_API(out_err, out_size, buffer, desc, flags);
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::Send(sf::Out<s32> out_err, sf::Out<s64> out_size, s32 desc, const sf::InBuffer &buffer, s32 flags) {
|
||||
/* NOTE: This is a deprecated API, and Nintendo aborts when it is called. */
|
||||
AMS_HTCS_MANAGER_DEPRECATED_API(out_err, out_size, desc, buffer, flags);
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::Shutdown(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, s32 how) {
|
||||
/* NOTE: This is a deprecated API, and Nintendo aborts when it is called. */
|
||||
AMS_HTCS_MANAGER_DEPRECATED_API(out_err, out_res, desc, how);
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::Fcntl(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, s32 command, s32 value) {
|
||||
/* NOTE: This is a deprecated API, and Nintendo aborts when it is called. */
|
||||
AMS_HTCS_MANAGER_DEPRECATED_API(out_err, out_res, desc, command, value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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>
|
||||
|
||||
namespace ams::htcs::server {
|
||||
|
||||
struct ServiceObjectAllocatorTag;
|
||||
using ServiceObjectAllocator = ams::sf::ExpHeapStaticAllocator<32_KB, ServiceObjectAllocatorTag>;
|
||||
using ServiceObjectFactory = ams::sf::ObjectFactory<typename ServiceObjectAllocator::Policy>;
|
||||
|
||||
}
|
||||
@@ -1,333 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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 "htcs_socket_service_object.hpp"
|
||||
#include "htcs_service_object_allocator.hpp"
|
||||
#include "../impl/htcs_manager.hpp"
|
||||
|
||||
namespace ams::htcs::server {
|
||||
|
||||
SocketServiceObject::SocketServiceObject(ManagerServiceObject *manager, s32 desc) : m_manager(manager, true), m_desc(desc) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
SocketServiceObject::~SocketServiceObject() {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Close the underlying socket. */
|
||||
s32 dummy_err, dummy_res;
|
||||
manager->Close(std::addressof(dummy_err), std::addressof(dummy_res), m_desc);
|
||||
}
|
||||
|
||||
Result SocketServiceObject::Close(sf::Out<s32> out_err, sf::Out<s32> out_res) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Close the underlying socket. */
|
||||
manager->Close(out_err.GetPointer(), out_res.GetPointer(), m_desc);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::Connect(sf::Out<s32> out_err, sf::Out<s32> out_res, const htcs::SockAddrHtcs &address) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Perform the connect. */
|
||||
manager->Connect(out_err.GetPointer(), out_res.GetPointer(), address, m_desc);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::Bind(sf::Out<s32> out_err, sf::Out<s32> out_res, const htcs::SockAddrHtcs &address) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Perform the bind. */
|
||||
manager->Bind(out_err.GetPointer(), out_res.GetPointer(), address, m_desc);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::Listen(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 backlog_count) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Perform the listen. */
|
||||
manager->Listen(out_err.GetPointer(), out_res.GetPointer(), backlog_count, m_desc);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::Recv(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutAutoSelectBuffer &buffer, s32 flags) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Perform the recv. */
|
||||
manager->Recv(out_err.GetPointer(), out_size.GetPointer(), reinterpret_cast<char *>(buffer.GetPointer()), buffer.GetSize(), flags, m_desc);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::Send(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::InAutoSelectBuffer &buffer, s32 flags) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Perform the send. */
|
||||
manager->Send(out_err.GetPointer(), out_size.GetPointer(), reinterpret_cast<const char *>(buffer.GetPointer()), buffer.GetSize(), flags, m_desc);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::Shutdown(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 how) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Perform the shutdown. */
|
||||
manager->Shutdown(out_err.GetPointer(), out_res.GetPointer(), how, m_desc);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::Fcntl(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 command, s32 value) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Perform the fcntl. */
|
||||
manager->Fcntl(out_err.GetPointer(), out_res.GetPointer(), command, value, m_desc);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::AcceptStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Start the accept. */
|
||||
os::NativeHandle event_handle;
|
||||
R_TRY(manager->AcceptStart(out_task_id.GetPointer(), std::addressof(event_handle), m_desc));
|
||||
|
||||
/* Set the output event handle. */
|
||||
out_event.SetValue(event_handle, true);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::AcceptResults(sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, sf::Out<htcs::SockAddrHtcs> out_address, u32 task_id) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Get the accept results. */
|
||||
s32 desc = -1;
|
||||
manager->AcceptResults(out_err.GetPointer(), std::addressof(desc), out_address.GetPointer(), task_id, m_desc);
|
||||
|
||||
/* If an error occurred, we're done. */
|
||||
R_SUCCEED_IF(*out_err != 0);
|
||||
|
||||
/* Create a new socket object. */
|
||||
*out = ServiceObjectFactory::CreateSharedEmplaced<tma::ISocket, SocketServiceObject>(m_manager.Get(), desc);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::RecvStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, s32 mem_size, s32 flags) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Start the recv. */
|
||||
os::NativeHandle event_handle;
|
||||
R_TRY(manager->RecvStart(out_task_id.GetPointer(), std::addressof(event_handle), mem_size, m_desc, flags));
|
||||
|
||||
/* Set the output event handle. */
|
||||
out_event.SetValue(event_handle, true);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::RecvResults(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Get the recv results. */
|
||||
manager->RecvResults(out_err.GetPointer(), out_size.GetPointer(), reinterpret_cast<char *>(buffer.GetPointer()), buffer.GetSize(), task_id, m_desc);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::RecvLargeStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, s32 unaligned_size_start, s32 unaligned_size_end, s64 aligned_size, sf::CopyHandle &&mem_handle, s32 flags) {
|
||||
/* Check that the transfer memory size is okay. */
|
||||
R_UNLESS(util::IsIntValueRepresentable<size_t>(aligned_size), htcs::ResultInvalidSize());
|
||||
|
||||
/* Attach the transfer memory. */
|
||||
os::TransferMemoryType tmem;
|
||||
os::AttachTransferMemory(std::addressof(tmem), static_cast<size_t>(aligned_size), mem_handle.GetOsHandle(), mem_handle.IsManaged());
|
||||
mem_handle.Detach();
|
||||
ON_SCOPE_EXIT { os::DestroyTransferMemory(std::addressof(tmem)); };
|
||||
|
||||
/* Map the transfer memory. */
|
||||
void *address;
|
||||
R_TRY(os::MapTransferMemory(std::addressof(address), std::addressof(tmem), os::MemoryPermission_None));
|
||||
ON_SCOPE_EXIT { os::UnmapTransferMemory(std::addressof(tmem)); };
|
||||
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Start the large receive. */
|
||||
os::NativeHandle event_handle;
|
||||
R_TRY(manager->RecvStart(out_task_id.GetPointer(), std::addressof(event_handle), unaligned_size_start + aligned_size + unaligned_size_end, m_desc, flags));
|
||||
|
||||
/* Set the output event handle. */
|
||||
out_event.SetValue(event_handle, true);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::SendStartOld(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &buffer, s32 flags) {
|
||||
R_RETURN(this->SendStart(out_task_id, out_event, sf::InNonSecureAutoSelectBuffer(buffer.GetPointer(), buffer.GetSize()), flags));
|
||||
}
|
||||
|
||||
Result SocketServiceObject::SendLargeStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &start_buffer, const sf::InAutoSelectBuffer &end_buffer, sf::CopyHandle &&mem_handle, s64 aligned_size, s32 flags) {
|
||||
/* Check that the sizes are okay. */
|
||||
R_UNLESS(util::IsIntValueRepresentable<s64>(start_buffer.GetSize()), htcs::ResultInvalidSize());
|
||||
R_UNLESS(util::IsIntValueRepresentable<s64>(end_buffer.GetSize()), htcs::ResultInvalidSize());
|
||||
R_UNLESS(util::IsIntValueRepresentable<size_t>(aligned_size), htcs::ResultInvalidSize());
|
||||
|
||||
/* Attach the transfer memory. */
|
||||
os::TransferMemoryType tmem;
|
||||
os::AttachTransferMemory(std::addressof(tmem), static_cast<size_t>(aligned_size), mem_handle.GetOsHandle(), mem_handle.IsManaged());
|
||||
mem_handle.Detach();
|
||||
ON_SCOPE_EXIT { os::DestroyTransferMemory(std::addressof(tmem)); };
|
||||
|
||||
/* Map the transfer memory. */
|
||||
void *address;
|
||||
R_TRY(os::MapTransferMemory(std::addressof(address), std::addressof(tmem), os::MemoryPermission_None));
|
||||
ON_SCOPE_EXIT { os::UnmapTransferMemory(std::addressof(tmem)); };
|
||||
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Start the large send. */
|
||||
constexpr auto NumBuffers = 3;
|
||||
const char *pointers[NumBuffers] = { reinterpret_cast<const char *>(start_buffer.GetPointer()), static_cast<const char *>(address), reinterpret_cast<const char *>(end_buffer.GetPointer()) };
|
||||
s64 sizes[NumBuffers] = { static_cast<s64>(start_buffer.GetSize()), aligned_size, static_cast<s64>(end_buffer.GetSize()) };
|
||||
|
||||
os::NativeHandle event_handle;
|
||||
R_TRY(manager->SendLargeStart(out_task_id.GetPointer(), std::addressof(event_handle), pointers, sizes, NumBuffers, m_desc, flags));
|
||||
|
||||
/* Set the output event handle. */
|
||||
out_event.SetValue(event_handle, true);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::SendResults(sf::Out<s32> out_err, sf::Out<s64> out_size, u32 task_id) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Get the send results. */
|
||||
manager->SendResults(out_err.GetPointer(), out_size.GetPointer(), task_id, m_desc);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::StartSend(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, sf::Out<s64> out_max_size, s64 size, s32 flags) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Start the send. */
|
||||
os::NativeHandle event_handle;
|
||||
R_TRY(manager->StartSend(out_task_id.GetPointer(), std::addressof(event_handle), m_desc, size, flags));
|
||||
|
||||
/* Set the output max size to the size. */
|
||||
*out_max_size = size;
|
||||
|
||||
/* Set the output event handle. */
|
||||
out_event.SetValue(event_handle, true);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::ContinueSendOld(sf::Out<s64> out_size, sf::Out<bool> out_wait, const sf::InAutoSelectBuffer &buffer, u32 task_id) {
|
||||
R_RETURN(this->ContinueSend(out_size, out_wait, sf::InNonSecureAutoSelectBuffer(buffer.GetPointer(), buffer.GetSize()), task_id));
|
||||
}
|
||||
|
||||
Result SocketServiceObject::EndSend(sf::Out<s32> out_err, sf::Out<s64> out_size, u32 task_id) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* End the send. */
|
||||
manager->EndSend(out_err.GetPointer(), out_size.GetPointer(), task_id, m_desc);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::StartRecv(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, s64 size, s32 flags) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Start the recv. */
|
||||
os::NativeHandle event_handle;
|
||||
R_TRY(manager->StartRecv(out_task_id.GetPointer(), std::addressof(event_handle), size, m_desc, flags));
|
||||
|
||||
/* Set the output event handle. */
|
||||
out_event.SetValue(event_handle, true);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::EndRecv(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id) {
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* End the recv. */
|
||||
manager->EndRecv(out_err.GetPointer(), out_size.GetPointer(), reinterpret_cast<char *>(buffer.GetPointer()), buffer.GetSize(), task_id, m_desc);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::SendStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InNonSecureAutoSelectBuffer &buffer, s32 flags) {
|
||||
/* Check that the sizes are okay. */
|
||||
R_UNLESS(util::IsIntValueRepresentable<s64>(buffer.GetSize()), htcs::ResultInvalidSize());
|
||||
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Start the send. */
|
||||
os::NativeHandle event_handle;
|
||||
R_TRY(manager->SendStart(out_task_id.GetPointer(), std::addressof(event_handle), reinterpret_cast<const char *>(buffer.GetPointer()), buffer.GetSize(), m_desc, flags));
|
||||
|
||||
/* Set the output event handle. */
|
||||
out_event.SetValue(event_handle, true);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::ContinueSend(sf::Out<s64> out_size, sf::Out<bool> out_wait, const sf::InNonSecureAutoSelectBuffer &buffer, u32 task_id) {
|
||||
/* Check that the sizes are okay. */
|
||||
R_UNLESS(util::IsIntValueRepresentable<s64>(buffer.GetSize()), htcs::ResultInvalidSize());
|
||||
|
||||
/* Get the htcs manager. */
|
||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||
|
||||
/* Continue the send. */
|
||||
R_TRY(manager->ContinueSend(out_size.GetPointer(), reinterpret_cast<const char *>(buffer.GetPointer()), buffer.GetSize(), task_id, m_desc));
|
||||
|
||||
/* We aren't doing a waiting send. */
|
||||
*out_wait = false;
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result SocketServiceObject::GetPrimitive(sf::Out<s32> out) {
|
||||
/* Get our descriptor. */
|
||||
*out = m_desc;
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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 "htcs_manager_service_object.hpp"
|
||||
|
||||
namespace ams::htcs::server {
|
||||
|
||||
class SocketServiceObject {
|
||||
private:
|
||||
sf::SharedPointer<ManagerServiceObject> m_manager;
|
||||
s32 m_desc;
|
||||
public:
|
||||
SocketServiceObject(ManagerServiceObject *manager, s32 desc);
|
||||
~SocketServiceObject();
|
||||
public:
|
||||
Result Close(sf::Out<s32> out_err, sf::Out<s32> out_res);
|
||||
Result Connect(sf::Out<s32> out_err, sf::Out<s32> out_res, const htcs::SockAddrHtcs &address);
|
||||
Result Bind(sf::Out<s32> out_err, sf::Out<s32> out_res, const htcs::SockAddrHtcs &address);
|
||||
Result Listen(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 backlog_count);
|
||||
Result Accept(sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, sf::Out<htcs::SockAddrHtcs> out_address);
|
||||
Result Recv(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutAutoSelectBuffer &buffer, s32 flags);
|
||||
Result Send(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::InAutoSelectBuffer &buffer, s32 flags);
|
||||
Result Shutdown(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 how);
|
||||
Result Fcntl(sf::Out<s32> out_err, sf::Out<s32> out_res, s32 command, s32 value);
|
||||
Result AcceptStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event);
|
||||
Result AcceptResults(sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, sf::Out<htcs::SockAddrHtcs> out_address, u32 task_id);
|
||||
Result RecvStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, s32 mem_size, s32 flags);
|
||||
Result RecvResults(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id);
|
||||
Result RecvLargeStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, s32 unaligned_size_start, s32 unaligned_size_end, s64 aligned_size, sf::CopyHandle &&mem_handle, s32 flags);
|
||||
Result SendStartOld(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &buffer, s32 flags);
|
||||
Result SendLargeStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &start_buffer, const sf::InAutoSelectBuffer &end_buffer, sf::CopyHandle &&mem_handle, s64 aligned_size, s32 flags);
|
||||
Result SendResults(sf::Out<s32> out_err, sf::Out<s64> out_size, u32 task_id);
|
||||
Result StartSend(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, sf::Out<s64> out_max_size, s64 size, s32 flags);
|
||||
Result ContinueSendOld(sf::Out<s64> out_size, sf::Out<bool> out_wait, const sf::InAutoSelectBuffer &buffer, u32 task_id);
|
||||
Result EndSend(sf::Out<s32> out_err, sf::Out<s64> out_size, u32 task_id);
|
||||
Result StartRecv(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, s64 size, s32 flags);
|
||||
Result EndRecv(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id);
|
||||
Result SendStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InNonSecureAutoSelectBuffer &buffer, s32 flags);
|
||||
Result ContinueSend(sf::Out<s64> out_size, sf::Out<bool> out_wait, const sf::InNonSecureAutoSelectBuffer &buffer, u32 task_id);
|
||||
Result GetPrimitive(sf::Out<s32> out);
|
||||
};
|
||||
static_assert(tma::IsISocket<SocketServiceObject>);
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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 "htcs_manager_service_object.hpp"
|
||||
#include "htcs_socket_service_object.hpp"
|
||||
|
||||
namespace ams::htcs::server {
|
||||
|
||||
#define AMS_HTCS_MANAGER_DEPRECATED_API(...) ({ AMS_UNUSED(__VA_ARGS__); AMS_ABORT("Deprecated IHtcsManager API %s was called.\n", AMS_CURRENT_FUNCTION_NAME); })
|
||||
|
||||
Result SocketServiceObject::Accept(sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, sf::Out<htcs::SockAddrHtcs> out_address) {
|
||||
/* NOTE: This is a deprecated API, and Nintendo aborts when it is called. */
|
||||
AMS_HTCS_MANAGER_DEPRECATED_API(out_err, out, out_address);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user