mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-10 07:06:34 +00:00
htcs: hook manager up to (unimplemented) manager impl
This commit is contained in:
parent
61929d6e21
commit
1541985222
12 changed files with 493 additions and 5 deletions
|
@ -38,6 +38,6 @@
|
||||||
AMS_SF_METHOD_INFO(C, H, 100, Result, RegisterProcessId, (const sf::ClientProcessId &client_pid), (client_pid)) \
|
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, 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, 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_METHOD_INFO(C, H, 131, 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), (out_err, out_count, read_handles, write_handles, exception_handles, task_id))
|
||||||
|
|
||||||
AMS_SF_DEFINE_INTERFACE(ams::tma, IHtcsManager, AMS_TMA_I_HTCS_MANAGER_INTERFACE_INFO)
|
AMS_SF_DEFINE_INTERFACE(ams::tma, IHtcsManager, AMS_TMA_I_HTCS_MANAGER_INTERFACE_INFO)
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <stratosphere.hpp>
|
#include <stratosphere.hpp>
|
||||||
#include "htcs_manager.hpp"
|
#include "htcs_manager.hpp"
|
||||||
#include "htcs_manager_impl.hpp"
|
#include "htcs_manager_impl.hpp"
|
||||||
|
#include "htcs_util.hpp"
|
||||||
|
|
||||||
namespace ams::htcs::impl {
|
namespace ams::htcs::impl {
|
||||||
|
|
||||||
|
@ -36,4 +37,362 @@ namespace ams::htcs::impl {
|
||||||
return m_impl->IsServiceAvailable();
|
return m_impl->IsServiceAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HtcsManager::Socket(s32 *out_err, s32 *out_desc, bool enable_disconnection_emulation) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
s32 err, desc;
|
||||||
|
const Result result = m_impl->CreateSocket(std::addressof(err), std::addressof(desc), enable_disconnection_emulation);
|
||||||
|
|
||||||
|
/* Set output. */
|
||||||
|
if (R_SUCCEEDED(result)) {
|
||||||
|
*out_err = err;
|
||||||
|
if (out_err == 0) {
|
||||||
|
*out_desc = desc;
|
||||||
|
} else {
|
||||||
|
*out_desc = -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*out_err = ConvertResultToErrorCode(result);
|
||||||
|
*out_desc = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtcsManager::Close(s32 *out_err, s32 *out_res, s32 desc) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
s32 err;
|
||||||
|
const Result result = m_impl->DestroySocket(std::addressof(err), desc);
|
||||||
|
|
||||||
|
/* Set output. */
|
||||||
|
*out_err = ConvertResultToErrorCode(result);
|
||||||
|
if (R_SUCCEEDED(result)) {
|
||||||
|
*out_res = 0;
|
||||||
|
} else {
|
||||||
|
*out_res = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtcsManager::Connect(s32 *out_err, s32 *out_res, const SockAddrHtcs &address, s32 desc) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
s32 err;
|
||||||
|
const Result result = m_impl->Connect(std::addressof(err), desc, address);
|
||||||
|
|
||||||
|
/* Set output. */
|
||||||
|
if (R_SUCCEEDED(result)) {
|
||||||
|
*out_err = err;
|
||||||
|
if (out_err == 0) {
|
||||||
|
*out_res = 0;
|
||||||
|
} else {
|
||||||
|
*out_res = -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*out_err = ConvertResultToErrorCode(result);
|
||||||
|
*out_res = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtcsManager::Bind(s32 *out_err, s32 *out_res, const SockAddrHtcs &address, s32 desc) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
s32 err;
|
||||||
|
const Result result = m_impl->Bind(std::addressof(err), desc, address);
|
||||||
|
|
||||||
|
/* Set output. */
|
||||||
|
if (R_SUCCEEDED(result)) {
|
||||||
|
*out_err = err;
|
||||||
|
if (out_err == 0) {
|
||||||
|
*out_res = 0;
|
||||||
|
} else {
|
||||||
|
*out_res = -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*out_err = ConvertResultToErrorCode(result);
|
||||||
|
*out_res = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtcsManager::Listen(s32 *out_err, s32 *out_res, s32 backlog_count, s32 desc) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
s32 err;
|
||||||
|
const Result result = m_impl->Listen(std::addressof(err), desc, backlog_count);
|
||||||
|
|
||||||
|
/* Set output. */
|
||||||
|
if (R_SUCCEEDED(result)) {
|
||||||
|
*out_err = err;
|
||||||
|
if (out_err == 0) {
|
||||||
|
*out_res = 0;
|
||||||
|
} else {
|
||||||
|
*out_res = -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*out_err = ConvertResultToErrorCode(result);
|
||||||
|
*out_res = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtcsManager::Recv(s32 *out_err, s64 *out_size, char *buffer, size_t size, s32 flags, s32 desc) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
s32 err;
|
||||||
|
s64 recv_size;
|
||||||
|
const Result result = m_impl->Recv(std::addressof(err), std::addressof(recv_size), buffer, size, desc, flags);
|
||||||
|
|
||||||
|
/* Set output. */
|
||||||
|
if (R_SUCCEEDED(result)) {
|
||||||
|
*out_err = err;
|
||||||
|
if (out_err == 0) {
|
||||||
|
*out_size = recv_size;
|
||||||
|
} else {
|
||||||
|
*out_size = -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*out_err = ConvertResultToErrorCode(result);
|
||||||
|
*out_size = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtcsManager::Send(s32 *out_err, s64 *out_size, const char *buffer, size_t size, s32 flags, s32 desc) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
s32 err;
|
||||||
|
s64 send_size;
|
||||||
|
const Result result = m_impl->Send(std::addressof(err), std::addressof(send_size), buffer, size, desc, flags);
|
||||||
|
|
||||||
|
/* Set output. */
|
||||||
|
if (R_SUCCEEDED(result)) {
|
||||||
|
*out_err = err;
|
||||||
|
if (out_err == 0) {
|
||||||
|
*out_size = send_size;
|
||||||
|
} else {
|
||||||
|
*out_size = -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*out_err = ConvertResultToErrorCode(result);
|
||||||
|
*out_size = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtcsManager::Shutdown(s32 *out_err, s32 *out_res, s32 how, s32 desc) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
s32 err;
|
||||||
|
const Result result = m_impl->Shutdown(std::addressof(err), desc, how);
|
||||||
|
|
||||||
|
/* Set output. */
|
||||||
|
if (R_SUCCEEDED(result)) {
|
||||||
|
*out_err = err;
|
||||||
|
if (out_err == 0) {
|
||||||
|
*out_res = 0;
|
||||||
|
} else {
|
||||||
|
*out_res = -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (htcs::ResultInvalidHandle::Includes(result)) {
|
||||||
|
*out_err = HTCS_ENOTCONN;
|
||||||
|
} else {
|
||||||
|
*out_err = ConvertResultToErrorCode(result);
|
||||||
|
}
|
||||||
|
*out_res = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtcsManager::Fcntl(s32 *out_err, s32 *out_res, s32 command, s32 value, s32 desc) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
s32 err, res;
|
||||||
|
const Result result = m_impl->Fcntl(std::addressof(err), std::addressof(res), desc, command, value);
|
||||||
|
|
||||||
|
/* Set output. */
|
||||||
|
if (R_SUCCEEDED(result)) {
|
||||||
|
*out_err = err;
|
||||||
|
*out_res = res;
|
||||||
|
} else {
|
||||||
|
*out_err = ConvertResultToErrorCode(result);
|
||||||
|
*out_res = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Result HtcsManager::AcceptStart(u32 *out_task_id, Handle *out_handle, s32 desc) {
|
||||||
|
return m_impl->AcceptStart(out_task_id, out_handle, desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtcsManager::AcceptResults(s32 *out_err, s32 *out_desc, SockAddrHtcs *out_address, u32 task_id, s32 desc) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
s32 err;
|
||||||
|
const Result result = m_impl->AcceptResults(std::addressof(err), out_desc, out_address, task_id, desc);
|
||||||
|
|
||||||
|
/* Set output. */
|
||||||
|
if (R_SUCCEEDED(result)) {
|
||||||
|
*out_err = err;
|
||||||
|
} else {
|
||||||
|
if (htc::ResultCancelled::Includes(result)) {
|
||||||
|
*out_err = HTCS_ENETDOWN;
|
||||||
|
} else if (htc::ResultUnknown2033::Includes(result)) {
|
||||||
|
*out_err = HTCS_EINTR;
|
||||||
|
} else {
|
||||||
|
*out_err = ConvertResultToErrorCode(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Result HtcsManager::RecvStart(u32 *out_task_id, Handle *out_handle, s64 size, s32 desc, s32 flags) {
|
||||||
|
return m_impl->RecvStart(out_task_id, out_handle, size, desc, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtcsManager::RecvResults(s32 *out_err, s64 *out_size, char *buffer, s64 buffer_size, u32 task_id, s32 desc) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
s32 err;
|
||||||
|
s64 size;
|
||||||
|
const Result result = m_impl->RecvResults(std::addressof(err), std::addressof(size), buffer, buffer_size, task_id, desc);
|
||||||
|
|
||||||
|
/* Set output. */
|
||||||
|
if (R_SUCCEEDED(result)) {
|
||||||
|
*out_err = err;
|
||||||
|
if (err == 0) {
|
||||||
|
*out_size = size;
|
||||||
|
} else {
|
||||||
|
*out_size = -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (htc::ResultUnknown2033::Includes(result)) {
|
||||||
|
*out_err = HTCS_EINTR;
|
||||||
|
} else {
|
||||||
|
*out_err = ConvertResultToErrorCode(result);
|
||||||
|
}
|
||||||
|
*out_size = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Result HtcsManager::SendStart(u32 *out_task_id, Handle *out_handle, const char *buffer, s64 size, s32 desc, s32 flags) {
|
||||||
|
return m_impl->SendStart(out_task_id, out_handle, buffer, size, desc, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result HtcsManager::SendLargeStart(u32 *out_task_id, Handle *out_handle, const char **buffers, const s64 *sizes, s32 count, s32 desc, s32 flags) {
|
||||||
|
return m_impl->SendLargeStart(out_task_id, out_handle, buffers, sizes, count, desc, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtcsManager::SendResults(s32 *out_err, s64 *out_size, u32 task_id, s32 desc) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
s32 err;
|
||||||
|
s64 size;
|
||||||
|
const Result result = m_impl->SendResults(std::addressof(err), std::addressof(size), task_id, desc);
|
||||||
|
|
||||||
|
/* Set output. */
|
||||||
|
if (R_SUCCEEDED(result)) {
|
||||||
|
*out_err = err;
|
||||||
|
if (err == 0) {
|
||||||
|
*out_size = size;
|
||||||
|
} else {
|
||||||
|
*out_size = -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (htc::ResultUnknown2033::Includes(result)) {
|
||||||
|
*out_err = HTCS_EINTR;
|
||||||
|
} else {
|
||||||
|
*out_err = ConvertResultToErrorCode(result);
|
||||||
|
}
|
||||||
|
*out_size = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Result HtcsManager::StartSend(u32 *out_task_id, Handle *out_handle, s32 desc, s64 size, s32 flags) {
|
||||||
|
return m_impl->StartSend(out_task_id, out_handle, desc, size, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result HtcsManager::ContinueSend(s64 *out_size, const char *buffer, s64 buffer_size, u32 task_id, s32 desc) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
s64 size;
|
||||||
|
R_TRY_CATCH(m_impl->ContinueSend(std::addressof(size), buffer, buffer_size, task_id, desc)) {
|
||||||
|
R_CONVERT(htclow::ResultInvalidChannelState, tma::ResultUnknown())
|
||||||
|
R_CONVERT(htc::ResultUnknown2021, tma::ResultUnknown())
|
||||||
|
} R_END_TRY_CATCH;
|
||||||
|
|
||||||
|
/* Set output. */
|
||||||
|
*out_size = size;
|
||||||
|
return ResultSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtcsManager::EndSend(s32 *out_err, s64 *out_size, u32 task_id, s32 desc) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
s32 err;
|
||||||
|
s64 size;
|
||||||
|
const Result result = m_impl->EndSend(std::addressof(err), std::addressof(size), task_id, desc);
|
||||||
|
|
||||||
|
/* Set output. */
|
||||||
|
if (R_SUCCEEDED(result)) {
|
||||||
|
*out_err = err;
|
||||||
|
if (err == 0) {
|
||||||
|
*out_size = size;
|
||||||
|
} else {
|
||||||
|
*out_size = -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (htc::ResultUnknown2033::Includes(result)) {
|
||||||
|
*out_err = HTCS_EINTR;
|
||||||
|
} else {
|
||||||
|
*out_err = ConvertResultToErrorCode(result);
|
||||||
|
}
|
||||||
|
*out_size = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Result HtcsManager::StartRecv(u32 *out_task_id, Handle *out_handle, s64 size, s32 desc, s32 flags) {
|
||||||
|
return m_impl->StartRecv(out_task_id, out_handle, size, desc, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtcsManager::EndRecv(s32 *out_err, s64 *out_size, char *buffer, s64 buffer_size, u32 task_id, s32 desc) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
s32 err;
|
||||||
|
s64 size;
|
||||||
|
const Result result = m_impl->EndRecv(std::addressof(err), std::addressof(size), buffer, buffer_size, task_id, desc);
|
||||||
|
|
||||||
|
/* Set output. */
|
||||||
|
if (R_SUCCEEDED(result)) {
|
||||||
|
*out_err = err;
|
||||||
|
if (err == 0) {
|
||||||
|
*out_size = size;
|
||||||
|
} else {
|
||||||
|
*out_size = -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (htc::ResultCancelled::Includes(result) || htc::ResultUnknown2033::Includes(result)) {
|
||||||
|
*out_err = 0;
|
||||||
|
} else {
|
||||||
|
*out_err = ConvertResultToErrorCode(result);
|
||||||
|
}
|
||||||
|
*out_size = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Result HtcsManager::StartSelect(u32 *out_task_id, Handle *out_handle, Span<const int> read_handles, Span<const int> write_handles, Span<const int> exception_handles, s64 tv_sec, s64 tv_usec) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
R_TRY_CATCH(m_impl->StartSelect(out_task_id, out_handle, read_handles, write_handles, exception_handles, tv_sec, tv_usec)) {
|
||||||
|
R_CONVERT(htc::ResultUnknown2021, tma::ResultUnknown())
|
||||||
|
} R_END_TRY_CATCH;
|
||||||
|
|
||||||
|
return ResultSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
Result HtcsManager::EndSelect(s32 *out_err, s32 *out_count, Span<int> read_handles, Span<int> write_handles, Span<int> exception_handles, u32 task_id) {
|
||||||
|
/* Invoke our implementation. */
|
||||||
|
s32 err, res;
|
||||||
|
const Result result = m_impl->EndSelect(std::addressof(err), std::addressof(res), read_handles, write_handles, exception_handles, task_id);
|
||||||
|
|
||||||
|
/* Set output. */
|
||||||
|
if (R_SUCCEEDED(result) && res == 0) {
|
||||||
|
*out_err = err;
|
||||||
|
if (err == 0) {
|
||||||
|
const auto num_read = std::count_if(read_handles.begin(), read_handles.end(), [](int handle) { return handle != 0; });
|
||||||
|
const auto num_write = std::count_if(write_handles.begin(), write_handles.end(), [](int handle) { return handle != 0; });
|
||||||
|
const auto num_exception = std::count_if(exception_handles.begin(), exception_handles.end(), [](int handle) { return handle != 0; });
|
||||||
|
*out_count = num_read + num_write + num_exception;
|
||||||
|
} else {
|
||||||
|
*out_count = -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (R_SUCCEEDED(result)) {
|
||||||
|
*out_err = 0;
|
||||||
|
*out_count = 0;
|
||||||
|
} else {
|
||||||
|
*out_err = ConvertResultToErrorCode(err);
|
||||||
|
*out_count = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResultSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace ams::htcs::impl {
|
||||||
void EndRecv(s32 *out_err, s64 *out_size, char *buffer, s64 buffer_size, u32 task_id, s32 desc);
|
void EndRecv(s32 *out_err, s64 *out_size, char *buffer, s64 buffer_size, u32 task_id, s32 desc);
|
||||||
|
|
||||||
Result StartSelect(u32 *out_task_id, Handle *out_handle, Span<const int> read_handles, Span<const int> write_handles, Span<const int> exception_handles, s64 tv_sec, s64 tv_usec);
|
Result StartSelect(u32 *out_task_id, Handle *out_handle, Span<const int> read_handles, Span<const int> write_handles, Span<const int> exception_handles, s64 tv_sec, s64 tv_usec);
|
||||||
Result EndSelect(s32 *out_err, s32 *out_res, Span<int> read_handles, Span<int> write_handles, Span<int> exception_handles, u32 task_id);
|
Result EndSelect(s32 *out_err, s32 *out_count, Span<int> read_handles, Span<int> write_handles, Span<int> exception_handles, u32 task_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,36 @@ namespace ams::htcs::impl {
|
||||||
os::EventType *GetServiceAvailabilityEvent();
|
os::EventType *GetServiceAvailabilityEvent();
|
||||||
|
|
||||||
bool IsServiceAvailable();
|
bool IsServiceAvailable();
|
||||||
|
public:
|
||||||
|
Result CreateSocket(s32 *out_err, s32 *out_desc, bool enable_disconnection_emulation);
|
||||||
|
Result DestroySocket(s32 *out_err, s32 desc);
|
||||||
|
Result Connect(s32 *out_err, s32 desc, const SockAddrHtcs &address);
|
||||||
|
Result Bind(s32 *out_err, s32 desc, const SockAddrHtcs &address);
|
||||||
|
Result Listen(s32 *out_err, s32 desc, s32 backlog_count);
|
||||||
|
Result Recv(s32 *out_err, s64 *out_size, char *buffer, size_t size, s32 desc, s32 flags);
|
||||||
|
Result Send(s32 *out_err, s64 *out_size, const char *buffer, size_t size, s32 desc, s32 flags);
|
||||||
|
Result Shutdown(s32 *out_err, s32 desc, s32 how);
|
||||||
|
Result Fcntl(s32 *out_err, s32 *out_res, s32 desc, s32 command, s32 value);
|
||||||
|
|
||||||
|
Result AcceptStart(u32 *out_task_id, Handle *out_handle, s32 desc);
|
||||||
|
Result AcceptResults(s32 *out_err, s32 *out_desc, SockAddrHtcs *out_address, u32 task_id, s32 desc);
|
||||||
|
|
||||||
|
Result RecvStart(u32 *out_task_id, Handle *out_handle, s64 size, s32 desc, s32 flags);
|
||||||
|
Result RecvResults(s32 *out_err, s64 *out_size, char *buffer, s64 buffer_size, u32 task_id, s32 desc);
|
||||||
|
|
||||||
|
Result SendStart(u32 *out_task_id, Handle *out_handle, const char *buffer, s64 size, s32 desc, s32 flags);
|
||||||
|
Result SendLargeStart(u32 *out_task_id, Handle *out_handle, const char **buffers, const s64 *sizes, s32 count, s32 desc, s32 flags);
|
||||||
|
Result SendResults(s32 *out_err, s64 *out_size, u32 task_id, s32 desc);
|
||||||
|
|
||||||
|
Result StartSend(u32 *out_task_id, Handle *out_handle, s32 desc, s64 size, s32 flags);
|
||||||
|
Result ContinueSend(s64 *out_size, const char *buffer, s64 buffer_size, u32 task_id, s32 desc);
|
||||||
|
Result EndSend(s32 *out_err, s64 *out_size, u32 task_id, s32 desc);
|
||||||
|
|
||||||
|
Result StartRecv(u32 *out_task_id, Handle *out_handle, s64 size, s32 desc, s32 flags);
|
||||||
|
Result EndRecv(s32 *out_err, s64 *out_size, char *buffer, s64 buffer_size, u32 task_id, s32 desc);
|
||||||
|
|
||||||
|
Result StartSelect(u32 *out_task_id, Handle *out_handle, Span<const int> read_handles, Span<const int> write_handles, Span<const int> exception_handles, s64 tv_sec, s64 tv_usec);
|
||||||
|
Result EndSelect(s32 *out_err, s32 *out_res, Span<int> read_handles, Span<int> write_handles, Span<int> exception_handles, u32 task_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
44
libraries/libstratosphere/source/htcs/impl/htcs_util.cpp
Normal file
44
libraries/libstratosphere/source/htcs/impl/htcs_util.cpp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* 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 "htcs_util.hpp"
|
||||||
|
|
||||||
|
namespace ams::htcs::impl {
|
||||||
|
|
||||||
|
s32 ConvertResultToErrorCode(const Result result) {
|
||||||
|
/* Convert success. */
|
||||||
|
if (R_SUCCEEDED(result)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
R_TRY_CATCH(result) {
|
||||||
|
R_CATCH(htclow::ResultNonBlockingReceiveFailed) { return HTCS_EWOULDBLOCK; }
|
||||||
|
R_CATCH(htcs::ResultInvalidHandle) { return HTCS_EBADF; }
|
||||||
|
R_CATCH(htc::ResultUnknown2001) { return HTCS_EINVAL; }
|
||||||
|
R_CATCH(htc::ResultUnknown2101) { return HTCS_EMFILE; }
|
||||||
|
R_CATCH(htc::ResultUnknown2021) { return HTCS_EINTR; }
|
||||||
|
R_CATCH(htc::ResultInvalidTaskId) { return HTCS_EINTR; }
|
||||||
|
R_CATCH(htc::ResultCancelled) { return HTCS_EINTR; }
|
||||||
|
R_CATCH(htc::ResultUnknown2033) { return HTCS_ENETDOWN; }
|
||||||
|
R_CATCH(htclow::ResultConnectionFailure) { return HTCS_ENETDOWN; }
|
||||||
|
R_CATCH(htclow::ResultChannelNotExist) { return HTCS_ENOTCONN; }
|
||||||
|
R_CATCH_ALL() { return HTCS_EUNKNOWN; }
|
||||||
|
} R_END_TRY_CATCH_WITH_ABORT_UNLESS;
|
||||||
|
|
||||||
|
__builtin_unreachable();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
23
libraries/libstratosphere/source/htcs/impl/htcs_util.hpp
Normal file
23
libraries/libstratosphere/source/htcs/impl/htcs_util.hpp
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* 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>
|
||||||
|
|
||||||
|
namespace ams::htcs::impl {
|
||||||
|
|
||||||
|
s32 ConvertResultToErrorCode(const Result result);
|
||||||
|
|
||||||
|
}
|
|
@ -82,12 +82,12 @@ namespace ams::htcs::server {
|
||||||
return manager->StartSelect(out_task_id.GetPointer(), out_event.GetHandlePointer(), read_handles.ToSpan(), write_handles.ToSpan(), exception_handles.ToSpan(), tv_sec, tv_usec);
|
return manager->StartSelect(out_task_id.GetPointer(), out_event.GetHandlePointer(), read_handles.ToSpan(), write_handles.ToSpan(), exception_handles.ToSpan(), tv_sec, tv_usec);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ManagerServiceObject::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) {
|
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. */
|
/* Get the htcs manager. */
|
||||||
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
auto *manager = impl::HtcsManagerHolder::GetHtcsManager();
|
||||||
|
|
||||||
/* End the select. */
|
/* End the select. */
|
||||||
return manager->EndSelect(out_err.GetPointer(), out_res.GetPointer(), read_handles.ToSpan(), write_handles.ToSpan(), exception_handles.ToSpan(), task_id);
|
return manager->EndSelect(out_err.GetPointer(), out_count.GetPointer(), read_handles.ToSpan(), write_handles.ToSpan(), exception_handles.ToSpan(), task_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace ams::htcs::server {
|
||||||
Result RegisterProcessId(const sf::ClientProcessId &client_pid);
|
Result RegisterProcessId(const sf::ClientProcessId &client_pid);
|
||||||
Result MonitorManager(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 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_res, const sf::OutMapAliasArray<s32> &read_handles, const sf::OutMapAliasArray<s32> &write_handles, const sf::OutMapAliasArray<s32> &exception_handles, u32 task_id);
|
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>);
|
static_assert(tma::IsIHtcsManager<ManagerServiceObject>);
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
#include <vapours/results/spl_results.hpp>
|
#include <vapours/results/spl_results.hpp>
|
||||||
#include <vapours/results/svc_results.hpp>
|
#include <vapours/results/svc_results.hpp>
|
||||||
#include <vapours/results/time_results.hpp>
|
#include <vapours/results/time_results.hpp>
|
||||||
|
#include <vapours/results/tma_results.hpp>
|
||||||
#include <vapours/results/updater_results.hpp>
|
#include <vapours/results/updater_results.hpp>
|
||||||
#include <vapours/results/usb_results.hpp>
|
#include <vapours/results/usb_results.hpp>
|
||||||
#include <vapours/results/vi_results.hpp>
|
#include <vapours/results/vi_results.hpp>
|
||||||
|
|
|
@ -28,9 +28,13 @@ namespace ams::htc {
|
||||||
|
|
||||||
R_DEFINE_ERROR_RESULT(Unknown, 1023);
|
R_DEFINE_ERROR_RESULT(Unknown, 1023);
|
||||||
|
|
||||||
|
R_DEFINE_ERROR_RESULT(Unknown2001, 2001);
|
||||||
R_DEFINE_ERROR_RESULT(InvalidTaskId, 2003);
|
R_DEFINE_ERROR_RESULT(InvalidTaskId, 2003);
|
||||||
R_DEFINE_ERROR_RESULT(InvalidSize, 2011);
|
R_DEFINE_ERROR_RESULT(InvalidSize, 2011);
|
||||||
|
R_DEFINE_ERROR_RESULT(Unknown2021, 2021);
|
||||||
|
R_DEFINE_ERROR_RESULT(Unknown2033, 2033);
|
||||||
|
|
||||||
|
R_DEFINE_ERROR_RESULT(Unknown2101, 2101);
|
||||||
R_DEFINE_ERROR_RESULT(OutOfRpcTask, 2102);
|
R_DEFINE_ERROR_RESULT(OutOfRpcTask, 2102);
|
||||||
R_DEFINE_ERROR_RESULT(InvalidCategory, 2123);
|
R_DEFINE_ERROR_RESULT(InvalidCategory, 2123);
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ namespace ams::htcs {
|
||||||
|
|
||||||
R_DEFINE_NAMESPACE_RESULT_MODULE(4);
|
R_DEFINE_NAMESPACE_RESULT_MODULE(4);
|
||||||
|
|
||||||
|
R_DEFINE_ERROR_RESULT(InvalidHandle, 9);
|
||||||
|
|
||||||
R_DEFINE_ERROR_RESULT(InvalidSize, 2014);
|
R_DEFINE_ERROR_RESULT(InvalidSize, 2014);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
25
libraries/libvapours/include/vapours/results/tma_results.hpp
Normal file
25
libraries/libvapours/include/vapours/results/tma_results.hpp
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* 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/results/results_common.hpp>
|
||||||
|
|
||||||
|
namespace ams::tma {
|
||||||
|
|
||||||
|
R_DEFINE_NAMESPACE_RESULT_MODULE(12);
|
||||||
|
|
||||||
|
R_DEFINE_ERROR_RESULT(Unknown, 1);
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue