htcs: add sf interface info/types

This commit is contained in:
Michael Scire 2021-02-10 06:40:11 -08:00 committed by SciresM
parent 4d86863f2c
commit cb5a706659
6 changed files with 208 additions and 0 deletions

View file

@ -15,3 +15,4 @@
*/ */
#pragma once #pragma once
#include <stratosphere/htcs/htcs_types.hpp>

View file

@ -0,0 +1,109 @@
/*
* 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::htcs {
using ssize_t = intptr_t;
using AddressFamilyType = u16;
constexpr inline int PeerNameBufferLength = 32;
constexpr inline int PortNameBufferLength = 32;
constexpr inline int SocketCountMax = 40;
constexpr inline int FdSetSize = SocketCountMax;
struct HtcsPeerName {
char name[PeerNameBufferLength];
};
struct HtcsPortName {
char name[PortNameBufferLength];
};
struct SockAddrHtcs {
AddressFamilyType family;
HtcsPeerName peer_name;
HtcsPortName port_name;
};
struct TimeVal {
s64 tv_sec;
s64 tv_usec;
};
struct FdSet {
int fds[FdSetSize];
};
enum SocketError {
HTCS_ENONE = 0,
HTCS_EACCES = 2,
HTCS_EADDRINUSE = 3,
HTCS_EADDRNOTAVAIL = 4,
HTCS_EAGAIN = 6,
HTCS_EALREADY = 7,
HTCS_EBADF = 8,
HTCS_EBUSY = 10,
HTCS_ECONNABORTED = 13,
HTCS_ECONNREFUSED = 14,
HTCS_ECONNRESET = 15,
HTCS_EDESTADDRREQ = 17,
HTCS_EFAULT = 21,
HTCS_EINPROGRESS = 26,
HTCS_EINTR = 27,
HTCS_EINVAL = 28,
HTCS_EIO = 29,
HTCS_EISCONN = 30,
HTCS_EMFILE = 33,
HTCS_EMSGSIZE = 35,
HTCS_ENETDOWN = 38,
HTCS_ENETRESET = 39,
HTCS_ENOBUFS = 42,
HTCS_ENOMEM = 49,
HTCS_ENOTCONN = 56,
HTCS_ETIMEDOUT = 76,
HTCS_EUNKNOWN = 79,
HTCS_EWOULDBLOCK = HTCS_EAGAIN,
};
enum MessageFlag {
HTCS_MSG_PEEK = 1,
HTCS_MSG_WAITALL = 2,
};
enum ShutdownType {
HTCS_SHUT_RD = 0,
HTCS_SHUT_WR = 1,
HTCS_SHUT_RDWR = 2,
};
enum FcntlOperation {
HTCS_F_GETFL = 3,
HTCS_F_SETFL = 4,
};
enum FcntlFlag {
HTCS_O_NONBLOCK = 4,
};
enum AddressFamily {
HTCS_AF_HTCS = 0,
};
}

View file

@ -256,6 +256,8 @@ namespace ams::sf {
using InNonSecureBuffer = typename impl::InBufferImpl<BufferTransferMode::MapAlias, SfBufferAttr_HipcMapTransferAllowsNonSecure>; using InNonSecureBuffer = typename impl::InBufferImpl<BufferTransferMode::MapAlias, SfBufferAttr_HipcMapTransferAllowsNonSecure>;
using InNonDeviceBuffer = typename impl::InBufferImpl<BufferTransferMode::MapAlias, SfBufferAttr_HipcMapTransferAllowsNonDevice>; using InNonDeviceBuffer = typename impl::InBufferImpl<BufferTransferMode::MapAlias, SfBufferAttr_HipcMapTransferAllowsNonDevice>;
using InNonSecureAutoSelectBuffer = typename impl::InBufferImpl<BufferTransferMode::AutoSelect, SfBufferAttr_HipcMapTransferAllowsNonSecure>;
using OutBuffer = typename impl::OutBufferImpl<BufferTransferMode::MapAlias>; using OutBuffer = typename impl::OutBufferImpl<BufferTransferMode::MapAlias>;
using OutMapAliasBuffer = typename impl::OutBufferImpl<BufferTransferMode::MapAlias>; using OutMapAliasBuffer = typename impl::OutBufferImpl<BufferTransferMode::MapAlias>;
using OutPointerBuffer = typename impl::OutBufferImpl<BufferTransferMode::Pointer>; using OutPointerBuffer = typename impl::OutBufferImpl<BufferTransferMode::Pointer>;
@ -263,6 +265,8 @@ namespace ams::sf {
using OutNonSecureBuffer = typename impl::OutBufferImpl<BufferTransferMode::MapAlias, SfBufferAttr_HipcMapTransferAllowsNonSecure>; using OutNonSecureBuffer = typename impl::OutBufferImpl<BufferTransferMode::MapAlias, SfBufferAttr_HipcMapTransferAllowsNonSecure>;
using OutNonDeviceBuffer = typename impl::OutBufferImpl<BufferTransferMode::MapAlias, SfBufferAttr_HipcMapTransferAllowsNonDevice>; using OutNonDeviceBuffer = typename impl::OutBufferImpl<BufferTransferMode::MapAlias, SfBufferAttr_HipcMapTransferAllowsNonDevice>;
using OutNonSecureAutoSelectBuffer = typename impl::OutBufferImpl<BufferTransferMode::AutoSelect, SfBufferAttr_HipcMapTransferAllowsNonSecure>;
template<typename T> template<typename T>
using InArray = typename impl::InArrayImpl<T>; using InArray = typename impl::InArrayImpl<T>;
template<typename T> template<typename T>

View file

@ -16,3 +16,4 @@
#pragma once #pragma once
#include <stratosphere/tma/tma_i_htc_manager.hpp> #include <stratosphere/tma/tma_i_htc_manager.hpp>
#include <stratosphere/tma/tma_i_htcs_manager.hpp>

View file

@ -0,0 +1,43 @@
/*
* 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>
#include <stratosphere/htcs/htcs_types.hpp>
#include <stratosphere/tma/tma_i_socket.hpp>
/* NOTE: Minimum firmware version not enforced for any commands. */
#define AMS_TMA_I_HTCS_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Socket, (sf::Out<s32> out_err, sf::Out<s32> out_sock), (out_err, out_sock)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Close, (sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc), (out_err, out_res, desc)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, Connect, (sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, const htcs::SockAddrHtcs &address), (out_err, out_res, desc, address)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, Bind, (sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, const htcs::SockAddrHtcs &address), (out_err, out_res, desc, address)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, Listen, (sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, s32 backlog_count), (out_err, out_res, desc, backlog_count)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, Accept, (sf::Out<s32> out_err, sf::Out<s32> out_res, sf::Out<htcs::SockAddrHtcs> out_address, s32 desc), (out_err, out_res, out_address, desc)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, Recv, (sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutBuffer &buffer, s32 desc, s32 flags), (out_err, out_size, buffer, desc, flags)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, Send, (sf::Out<s32> out_err, sf::Out<s64> out_size, s32 desc, const sf::InBuffer &buffer, s32 flags), (out_err, out_size, desc, buffer, flags)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, Shutdown, (sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, s32 how), (out_err, out_res, desc, how)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, Fcntl, (sf::Out<s32> out_err, sf::Out<s32> out_res, s32 desc, s32 command, s32 value), (out_err, out_res, desc, command, value)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, GetPeerNameAny, (sf::Out<htcs::HtcsPeerName> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 11, Result, GetDefaultHostName, (sf::Out<htcs::HtcsPeerName> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 12, Result, CreateSocketOld, (sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out), (out_err, out)) \
AMS_SF_METHOD_INFO(C, H, 13, Result, CreateSocket, (sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, bool enable_disconnection_emulation), (out_err, out, enable_disconnection_emulation)) \
AMS_SF_METHOD_INFO(C, H, 100, Result, RegisterProcessId, (const sf::ClientProcessId &client_pid), (client_pid)) \
AMS_SF_METHOD_INFO(C, H, 101, Result, MonitorManager, (const sf::ClientProcessId &client_pid), (client_pid)) \
AMS_SF_METHOD_INFO(C, H, 130, 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), (out_task_id, out_event, read_handles, write_handles, exception_handles, tv_sec, tv_usec)) \
AMS_SF_METHOD_INFO(C, H, 131, Result, EndSelect, (sf::Out<s32> out_err, sf::Out<s32> out_res, const sf::OutMapAliasArray<s32> &read_handles, const sf::OutMapAliasArray<s32> &write_handles, const sf::OutMapAliasArray<s32> &exception_handles, u32 task_id), (out_err, out_res, read_handles, write_handles, exception_handles, task_id))
AMS_SF_DEFINE_INTERFACE(ams::tma, IHtcsManager, AMS_TMA_I_HTCS_MANAGER_INTERFACE_INFO)

View file

@ -0,0 +1,50 @@
/*
* 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>
#include <stratosphere/htcs/htcs_types.hpp>
#include <stratosphere/tma/tma_i_socket.hpp>
/* NOTE: Minimum firmware version not enforced for any commands. */
#define AMS_TMA_I_SOCKET_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Close, (sf::Out<s32> out_err, sf::Out<s32> out_res), (out_err, out_res)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Connect, (sf::Out<s32> out_err, sf::Out<s32> out_res, const htcs::SockAddrHtcs &address), (out_err, out_res, address)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, Bind, (sf::Out<s32> out_err, sf::Out<s32> out_res, const htcs::SockAddrHtcs &address), (out_err, out_res, address)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, Listen, (sf::Out<s32> out_err, sf::Out<s32> out_res, s32 backlog_count), (out_err, out_res, backlog_count)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, Accept, (sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, sf::Out<htcs::SockAddrHtcs> out_address), (out_err, out, out_address)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, Recv, (sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutAutoSelectBuffer &buffer, s32 flags), (out_err, out_size, buffer, flags)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, Send, (sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::InAutoSelectBuffer &buffer, s32 flags), (out_err, out_size, buffer, flags)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, Shutdown, (sf::Out<s32> out_err, sf::Out<s32> out_res, s32 how), (out_err, out_res, how)) \
AMS_SF_METHOD_INFO(C, H, 8, Result, Fcntl, (sf::Out<s32> out_err, sf::Out<s32> out_res, s32 command, s32 value), (out_err, out_res, command, value)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, AcceptStart, (sf::Out<u32> out_task_id, sf::OutCopyHandle out_event), (out_task_id, out_event)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, AcceptResults, (sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, sf::Out<htcs::SockAddrHtcs> out_address, u32 task_id), (out_err, out, out_address, task_id)) \
AMS_SF_METHOD_INFO(C, H, 11, Result, RecvStart, (sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, s32 mem_size, s32 flags), (out_task_id, out_event, mem_size, flags)) \
AMS_SF_METHOD_INFO(C, H, 12, Result, RecvResults, (sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id), (out_err, out_size, buffer, task_id)) \
AMS_SF_METHOD_INFO(C, H, 13, 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), (out_task_id, out_event, unaligned_size_start, unaligned_size_end, aligned_size, mem_handle, flags)) \
AMS_SF_METHOD_INFO(C, H, 14, Result, SendStartOld, (sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &buffer, s32 flags), (out_task_id, out_event, buffer, flags)) \
AMS_SF_METHOD_INFO(C, H, 15, 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), (out_task_id, out_event, start_buffer, end_buffer, mem_handle, aligned_size, flags)) \
AMS_SF_METHOD_INFO(C, H, 16, Result, SendResults, (sf::Out<s32> out_err, sf::Out<s64> out_size, u32 task_id), (out_err, out_size, task_id)) \
AMS_SF_METHOD_INFO(C, H, 17, Result, StartSend, (sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, sf::Out<s64> out_max_size, s64 size, s32 flags), (out_task_id, out_event, out_max_size, size, flags)) \
AMS_SF_METHOD_INFO(C, H, 18, Result, ContinueSendOld, (sf::Out<s64> out_size, sf::Out<bool> out_wait, const sf::InAutoSelectBuffer &buffer, u32 task_id), (out_size, out_wait, buffer, task_id)) \
AMS_SF_METHOD_INFO(C, H, 19, Result, EndSend, (sf::Out<s32> out_err, sf::Out<s64> out_size, u32 task_id), (out_err, out_size, task_id)) \
AMS_SF_METHOD_INFO(C, H, 20, Result, StartRecv, (sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, s64 size, s32 flags), (out_task_id, out_event, size, flags)) \
AMS_SF_METHOD_INFO(C, H, 21, Result, EndRecv, (sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id), (out_err, out_size, buffer, task_id)) \
AMS_SF_METHOD_INFO(C, H, 22, Result, SendStart, (sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InNonSecureAutoSelectBuffer &buffer, s32 flags), (out_task_id, out_event, buffer, flags)) \
AMS_SF_METHOD_INFO(C, H, 23, Result, ContinueSend, (sf::Out<s64> out_size, sf::Out<bool> out_wait, const sf::InNonSecureAutoSelectBuffer &buffer, u32 task_id), (out_size, out_wait, buffer, task_id)) \
AMS_SF_METHOD_INFO(C, H, 130, Result, GetPrimitive, (sf::Out<s32> out), (out))
AMS_SF_DEFINE_INTERFACE(ams::tma, ISocket, AMS_TMA_I_SOCKET_INTERFACE_INFO)