ams: support building unit test programs on windows/linux/macos
This commit is contained in:
@@ -15,13 +15,14 @@
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/tipc/tipc_message_types.hpp>
|
||||
#include <stratosphere/tipc/tipc_service_object_base.hpp>
|
||||
#include <stratosphere/tipc/impl/tipc_impl_command_serialization.hpp>
|
||||
|
||||
namespace ams::tipc::impl {
|
||||
|
||||
template<typename T>
|
||||
concept HasDefaultServiceCommandProcessor = requires (T &t, const svc::ipc::MessageBuffer &message_buffer) {
|
||||
concept HasDefaultServiceCommandProcessor = requires (T &t, const MessageBuffer &message_buffer) {
|
||||
{ t.ProcessDefaultServiceCommand(message_buffer) } -> std::same_as<Result>;
|
||||
};
|
||||
|
||||
@@ -129,7 +130,7 @@ namespace ams::tipc::impl {
|
||||
constexpr explicit ImplTemplateBaseT(Args &&...args) : ImplHolder(std::forward<Args>(args)...) { /* ... */ } \
|
||||
private: \
|
||||
template<typename ImplType> \
|
||||
ALWAYS_INLINE Result ProcessDefaultMethod(ImplType *impl, const svc::ipc::MessageBuffer &message_buffer) const { \
|
||||
ALWAYS_INLINE Result ProcessDefaultMethod(ImplType *impl, const MessageBuffer &message_buffer) const { \
|
||||
/* Handle a default command. */ \
|
||||
if constexpr (HasDefaultServiceCommandProcessor<ImplType>) { \
|
||||
return impl->ProcessDefaultServiceCommand(message_buffer); \
|
||||
@@ -139,7 +140,7 @@ namespace ams::tipc::impl {
|
||||
} \
|
||||
\
|
||||
template<u16 CommandId, typename ImplType> \
|
||||
ALWAYS_INLINE Result ProcessMethodById(ImplType *impl, const svc::ipc::MessageBuffer &message_buffer, hos::Version fw_ver) const { \
|
||||
ALWAYS_INLINE Result ProcessMethodById(ImplType *impl, const MessageBuffer &message_buffer, hos::Version fw_ver) const { \
|
||||
CMD_MACRO(ImplType, AMS_TIPC_IMPL_PROCESS_METHOD_REQUEST_BY_ID) \
|
||||
\
|
||||
return this->ProcessDefaultMethod<ImplType>(impl, message_buffer); \
|
||||
@@ -159,10 +160,10 @@ namespace ams::tipc::impl {
|
||||
static_assert(::NAMESPACE::Is##INTERFACE<ImplType>); \
|
||||
\
|
||||
/* Get accessor to the message buffer. */ \
|
||||
const svc::ipc::MessageBuffer message_buffer(svc::ipc::GetMessageBuffer()); \
|
||||
const MessageBuffer message_buffer(tipc::GetMessageBuffer()); \
|
||||
\
|
||||
/* Get decision variables. */ \
|
||||
const auto tag = svc::ipc::MessageBuffer::MessageHeader(message_buffer).GetTag(); \
|
||||
const auto tag = MessageBuffer::MessageHeader(message_buffer).GetTag(); \
|
||||
const auto fw_ver = IsFirmwareVersionAlwaysValid() ? hos::Version_Current : hos::GetVersion(); \
|
||||
\
|
||||
/* Process against the command ids. */ \
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace ams::tipc {
|
||||
|
||||
}
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
namespace ams::tipc::impl {
|
||||
|
||||
/* Machinery for filtering type lists. */
|
||||
@@ -302,21 +303,21 @@ namespace ams::tipc::impl {
|
||||
/* tipc-specific accessors. */
|
||||
static constexpr bool HasInSpecialHeader = HasProcessId || NumInHandles > 0;
|
||||
|
||||
static constexpr svc::ipc::MessageBuffer::MessageHeader InMessageHeader{CommandId, HasInSpecialHeader, 0, NumInBuffers, NumOutBuffers, 0, InDataSize / sizeof(u32), 0};
|
||||
static constexpr svc::ipc::MessageBuffer::SpecialHeader InSpecialHeader{HasProcessId, NumInCopyHandles, NumInMoveHandles, HasInSpecialHeader};
|
||||
static constexpr MessageBuffer::MessageHeader InMessageHeader{CommandId, HasInSpecialHeader, 0, NumInBuffers, NumOutBuffers, 0, InDataSize / sizeof(u32), 0};
|
||||
static constexpr MessageBuffer::SpecialHeader InSpecialHeader{HasProcessId, NumInCopyHandles, NumInMoveHandles, HasInSpecialHeader};
|
||||
|
||||
static constexpr auto InMessageProcessIdIndex = svc::ipc::MessageBuffer::GetSpecialDataIndex(InMessageHeader, InSpecialHeader);
|
||||
static constexpr auto InMessageHandleIndex = svc::ipc::MessageBuffer::GetSpecialDataIndex(InMessageHeader, InSpecialHeader) + (HasProcessId ? sizeof(u64) / sizeof(u32) : 0);
|
||||
static constexpr auto InMessageBufferIndex = svc::ipc::MessageBuffer::GetMapAliasDescriptorIndex(InMessageHeader, InSpecialHeader);
|
||||
static constexpr auto InMessageRawDataIndex = svc::ipc::MessageBuffer::GetRawDataIndex(InMessageHeader, InSpecialHeader);
|
||||
static constexpr auto InMessageProcessIdIndex = MessageBuffer::GetSpecialDataIndex(InMessageHeader, InSpecialHeader);
|
||||
static constexpr auto InMessageHandleIndex = MessageBuffer::GetSpecialDataIndex(InMessageHeader, InSpecialHeader) + (HasProcessId ? sizeof(u64) / sizeof(u32) : 0);
|
||||
static constexpr auto InMessageBufferIndex = MessageBuffer::GetMapAliasDescriptorIndex(InMessageHeader, InSpecialHeader);
|
||||
static constexpr auto InMessageRawDataIndex = MessageBuffer::GetRawDataIndex(InMessageHeader, InSpecialHeader);
|
||||
|
||||
static constexpr bool HasOutSpecialHeader = NumOutHandles > 0;
|
||||
|
||||
static constexpr svc::ipc::MessageBuffer::MessageHeader OutMessageHeader{CommandId, HasOutSpecialHeader, 0, 0, 0, 0, (OutDataSize / sizeof(u32)) + 1, 0};
|
||||
static constexpr svc::ipc::MessageBuffer::SpecialHeader OutSpecialHeader{false, NumOutCopyHandles, NumOutMoveHandles, HasOutSpecialHeader};
|
||||
static constexpr MessageBuffer::MessageHeader OutMessageHeader{CommandId, HasOutSpecialHeader, 0, 0, 0, 0, (OutDataSize / sizeof(u32)) + 1, 0};
|
||||
static constexpr MessageBuffer::SpecialHeader OutSpecialHeader{false, NumOutCopyHandles, NumOutMoveHandles, HasOutSpecialHeader};
|
||||
|
||||
static constexpr auto OutMessageHandleIndex = svc::ipc::MessageBuffer::GetSpecialDataIndex(OutMessageHeader, OutSpecialHeader);
|
||||
static constexpr auto OutMessageResultIndex = svc::ipc::MessageBuffer::GetRawDataIndex(OutMessageHeader, OutSpecialHeader);
|
||||
static constexpr auto OutMessageHandleIndex = MessageBuffer::GetSpecialDataIndex(OutMessageHeader, OutSpecialHeader);
|
||||
static constexpr auto OutMessageResultIndex = MessageBuffer::GetRawDataIndex(OutMessageHeader, OutSpecialHeader);
|
||||
static constexpr auto OutMessageRawDataIndex = OutMessageResultIndex + 1;
|
||||
|
||||
static constexpr size_t InMessageTotalSize = (InMessageRawDataIndex * sizeof(u32)) + InDataSize;
|
||||
@@ -410,7 +411,7 @@ namespace ams::tipc::impl {
|
||||
return reinterpret_cast<uintptr_t>(data + Offset);
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE void CopyTo(const svc::ipc::MessageBuffer &buffer) const {
|
||||
constexpr ALWAYS_INLINE void CopyTo(const MessageBuffer &buffer) const {
|
||||
if constexpr (Size > 0) {
|
||||
buffer.SetRawArray(OutIndex, data, Size);
|
||||
}
|
||||
@@ -423,24 +424,24 @@ namespace ams::tipc::impl {
|
||||
static constexpr size_t NumMove = _NumMove;
|
||||
static constexpr size_t NumCopy = _NumCopy;
|
||||
private:
|
||||
os::NativeHandle move_handles[NumMove];
|
||||
os::NativeHandle copy_handles[NumCopy];
|
||||
tipc::NativeHandle move_handles[NumMove];
|
||||
tipc::NativeHandle copy_handles[NumCopy];
|
||||
public:
|
||||
ALWAYS_INLINE OutHandleHolder() { /* ... */ }
|
||||
|
||||
template<size_t Index>
|
||||
constexpr ALWAYS_INLINE os::NativeHandle *GetMoveHandlePointer() {
|
||||
constexpr ALWAYS_INLINE tipc::NativeHandle *GetMoveHandlePointer() {
|
||||
static_assert(Index < NumMove, "Index < NumMove");
|
||||
return move_handles + Index;
|
||||
}
|
||||
|
||||
template<size_t Index>
|
||||
constexpr ALWAYS_INLINE os::NativeHandle *GetCopyHandlePointer() {
|
||||
constexpr ALWAYS_INLINE tipc::NativeHandle *GetCopyHandlePointer() {
|
||||
static_assert(Index < NumCopy, "Index < NumCopy");
|
||||
return copy_handles + Index;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void CopyTo(const svc::ipc::MessageBuffer &buffer) const {
|
||||
ALWAYS_INLINE void CopyTo(const MessageBuffer &buffer) const {
|
||||
#define _TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(n) do { if constexpr (NumCopy > n) { buffer.SetHandle(OutIndex + n, copy_handles[n]); } } while (0)
|
||||
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(0);
|
||||
_TIPC_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(1);
|
||||
@@ -475,7 +476,7 @@ namespace ams::tipc::impl {
|
||||
using OutRawHolderType = OutRawHolder<CommandMeta::OutDataSize, CommandMeta::OutDataAlign, CommandMeta::OutMessageRawDataIndex>;
|
||||
using OutHandleHolderType = OutHandleHolder<CommandMeta::NumOutMoveHandles, CommandMeta::NumOutCopyHandles, CommandMeta::OutMessageHandleIndex>;
|
||||
private:
|
||||
static constexpr u64 GetMessageHeaderForCheck(const svc::ipc::MessageBuffer::MessageHeader &header) {
|
||||
static constexpr u64 GetMessageHeaderForCheck(const MessageBuffer::MessageHeader &header) {
|
||||
using Value = util::BitPack32::Field<0, BITSIZEOF(util::BitPack32)>;
|
||||
|
||||
const util::BitPack32 *data = header.GetData();
|
||||
@@ -485,7 +486,7 @@ namespace ams::tipc::impl {
|
||||
return static_cast<u64>(lower) | (static_cast<u64>(upper) << BITSIZEOF(u32));
|
||||
}
|
||||
|
||||
static constexpr u32 GetSpecialHeaderForCheck(const svc::ipc::MessageBuffer::SpecialHeader &header) {
|
||||
static constexpr u32 GetSpecialHeaderForCheck(const MessageBuffer::SpecialHeader &header) {
|
||||
using Value = util::BitPack32::Field<0, BITSIZEOF(util::BitPack32)>;
|
||||
|
||||
return header.GetHeader()->Get<Value>();
|
||||
@@ -493,7 +494,7 @@ namespace ams::tipc::impl {
|
||||
|
||||
/* Argument deserialization. */
|
||||
template<size_t Index, typename T = typename std::tuple_element<Index, ArgsType>::type>
|
||||
static ALWAYS_INLINE typename std::tuple_element<Index, ArgsType>::type DeserializeArgumentImpl(const svc::ipc::MessageBuffer &message_buffer, const OutRawHolderType &out_raw_holder, OutHandleHolderType &out_handles_holder) {
|
||||
static ALWAYS_INLINE typename std::tuple_element<Index, ArgsType>::type DeserializeArgumentImpl(const MessageBuffer &message_buffer, const OutRawHolderType &out_raw_holder, OutHandleHolderType &out_handles_holder) {
|
||||
constexpr auto Info = CommandMeta::ArgumentSerializationInfos[Index];
|
||||
if constexpr (Info.arg_type == ArgumentType::InData) {
|
||||
/* New in rawdata. */
|
||||
@@ -524,12 +525,12 @@ namespace ams::tipc::impl {
|
||||
} else if constexpr (Info.arg_type == ArgumentType::OutHandle) {
|
||||
/* New OutHandle. */
|
||||
if constexpr (std::same_as<T, tipc::OutMoveHandle>) {
|
||||
os::NativeHandle * const ptr = out_handles_holder.template GetMoveHandlePointer<Info.out_move_handle_index>();
|
||||
*ptr = os::InvalidNativeHandle;
|
||||
tipc::NativeHandle * const ptr = out_handles_holder.template GetMoveHandlePointer<Info.out_move_handle_index>();
|
||||
*ptr = tipc::InvalidNativeHandle;
|
||||
return T(ptr);
|
||||
} else if constexpr (std::same_as<T, tipc::OutCopyHandle>) {
|
||||
os::NativeHandle * const ptr = out_handles_holder.template GetCopyHandlePointer<Info.out_copy_handle_index>();
|
||||
*ptr = os::InvalidNativeHandle;
|
||||
tipc::NativeHandle * const ptr = out_handles_holder.template GetCopyHandlePointer<Info.out_copy_handle_index>();
|
||||
*ptr = tipc::InvalidNativeHandle;
|
||||
return T(ptr);
|
||||
} else {
|
||||
static_assert(!std::is_same<T, T>::value, "Invalid OutHandle kind");
|
||||
@@ -537,19 +538,19 @@ namespace ams::tipc::impl {
|
||||
} else if constexpr (Info.arg_type == ArgumentType::Buffer) {
|
||||
/* NOTE: There are currently no tipc commands which use buffers-with-attributes */
|
||||
/* If these are added (e.g., NonSecure buffers), implement checking here? */
|
||||
constexpr size_t MapAliasDescriptorSize = svc::ipc::MessageBuffer::MapAliasDescriptor::GetDataSize();
|
||||
constexpr size_t MapAliasDescriptorSize = MessageBuffer::MapAliasDescriptor::GetDataSize();
|
||||
|
||||
if constexpr (Info.is_send_buffer) {
|
||||
/* Input send buffer. */
|
||||
constexpr auto BufferIndex = CommandMeta::InMessageBufferIndex + (Info.send_map_alias_index * MapAliasDescriptorSize / sizeof(util::BitPack32));
|
||||
|
||||
const svc::ipc::MessageBuffer::MapAliasDescriptor descriptor(message_buffer, BufferIndex);
|
||||
const MessageBuffer::MapAliasDescriptor descriptor(message_buffer, BufferIndex);
|
||||
return T(descriptor.GetAddress(), descriptor.GetSize());
|
||||
} else {
|
||||
/* Input receive buffer. */
|
||||
constexpr auto BufferIndex = CommandMeta::InMessageBufferIndex + ((CommandMeta::NumInBuffers + Info.recv_map_alias_index) * MapAliasDescriptorSize / sizeof(util::BitPack32));
|
||||
|
||||
const svc::ipc::MessageBuffer::MapAliasDescriptor descriptor(message_buffer, BufferIndex);
|
||||
const MessageBuffer::MapAliasDescriptor descriptor(message_buffer, BufferIndex);
|
||||
return T(descriptor.GetAddress(), descriptor.GetSize());
|
||||
}
|
||||
} else if constexpr (Info.arg_type == ArgumentType::ProcessId) {
|
||||
@@ -559,7 +560,7 @@ namespace ams::tipc::impl {
|
||||
}
|
||||
}
|
||||
public:
|
||||
static ALWAYS_INLINE Result ValidateCommandFormat(const svc::ipc::MessageBuffer &message_buffer) {
|
||||
static ALWAYS_INLINE Result ValidateCommandFormat(const MessageBuffer &message_buffer) {
|
||||
/* Validate the message header. */
|
||||
constexpr auto ExpectedMessageHeader = GetMessageHeaderForCheck(CommandMeta::InMessageHeader);
|
||||
R_UNLESS(message_buffer.Get64(0) == ExpectedMessageHeader, tipc::ResultInvalidMessageFormat());
|
||||
@@ -567,7 +568,7 @@ namespace ams::tipc::impl {
|
||||
/* Validate the special header. */
|
||||
if constexpr (CommandMeta::HasInSpecialHeader) {
|
||||
constexpr auto ExpectedSpecialHeader = GetSpecialHeaderForCheck(CommandMeta::InSpecialHeader);
|
||||
constexpr auto SpecialHeaderIndex = svc::ipc::MessageBuffer::MessageHeader::GetDataSize() / sizeof(util::BitPack32);
|
||||
constexpr auto SpecialHeaderIndex = MessageBuffer::MessageHeader::GetDataSize() / sizeof(util::BitPack32);
|
||||
R_UNLESS(message_buffer.Get32(SpecialHeaderIndex) == ExpectedSpecialHeader, tipc::ResultInvalidMessageFormat());
|
||||
}
|
||||
|
||||
@@ -575,11 +576,11 @@ namespace ams::tipc::impl {
|
||||
}
|
||||
|
||||
template<size_t Ix>
|
||||
static ALWAYS_INLINE auto DeserializeArgument(const svc::ipc::MessageBuffer &message_buffer, const OutRawHolderType &out_raw_holder, OutHandleHolderType &out_handles_holder) {
|
||||
static ALWAYS_INLINE auto DeserializeArgument(const MessageBuffer &message_buffer, const OutRawHolderType &out_raw_holder, OutHandleHolderType &out_handles_holder) {
|
||||
return DeserializeArgumentImpl<Ix>(message_buffer, out_raw_holder, out_handles_holder);
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE void SerializeResults(const svc::ipc::MessageBuffer &message_buffer, const Result &result, const OutRawHolderType &out_raw_holder, const OutHandleHolderType &out_handles_holder) {
|
||||
static ALWAYS_INLINE void SerializeResults(const MessageBuffer &message_buffer, const Result &result, const OutRawHolderType &out_raw_holder, const OutHandleHolderType &out_handles_holder) {
|
||||
/* Set output headers. */
|
||||
message_buffer.Set(CommandMeta::OutMessageHeader);
|
||||
if constexpr (CommandMeta::HasOutSpecialHeader) {
|
||||
@@ -607,7 +608,7 @@ namespace ams::tipc::impl {
|
||||
};
|
||||
|
||||
template<u16 _CommmandId, auto ServiceCommandImpl, typename ClassType>
|
||||
constexpr ALWAYS_INLINE Result InvokeServiceCommandImpl(ClassType *object, const svc::ipc::MessageBuffer &message_buffer) {
|
||||
constexpr ALWAYS_INLINE Result InvokeServiceCommandImpl(ClassType *object, const MessageBuffer &message_buffer) {
|
||||
using Return = decltype(FunctionTraits::GetReturnImpl(ServiceCommandImpl));
|
||||
using TrueArgumentsTuple = decltype(FunctionTraits::GetArgumentsImpl(ServiceCommandImpl));
|
||||
|
||||
@@ -641,3 +642,97 @@ namespace ams::tipc::impl {
|
||||
}
|
||||
|
||||
}
|
||||
#elif defined(ATMOSPHERE_OS_WINDOWS)
|
||||
namespace ams::tipc::impl {
|
||||
|
||||
template<u16 _CommandId, typename ArgumentsTuple>
|
||||
struct CommandMetaInfo;
|
||||
|
||||
template<u16 _CommandId, typename... Arguments>
|
||||
struct CommandMetaInfo<_CommandId, std::tuple<Arguments...>> {
|
||||
public:
|
||||
static constexpr size_t InMessageTotalSize = 0x40; /* TODO */
|
||||
static constexpr size_t OutMessageTotalSize = 0x40; /* TODO */
|
||||
};
|
||||
|
||||
template<typename CommandMeta>
|
||||
class CommandProcessor {
|
||||
public:
|
||||
static ALWAYS_INLINE Result ValidateCommandFormat(const MessageBuffer &) {
|
||||
AMS_ABORT("TODO");
|
||||
}
|
||||
};
|
||||
|
||||
template<u16 _CommmandId, auto ServiceCommandImpl, typename ClassType>
|
||||
ALWAYS_INLINE Result InvokeServiceCommandImpl(ClassType *object, const MessageBuffer &message_buffer) {
|
||||
/* TODO: Is some kind of emulated serialization interesting/desirable? */
|
||||
/* TIPC is generally a huge TODO. */
|
||||
AMS_UNUSED(object, message_buffer);
|
||||
AMS_ABORT("TIPC serialization not currently supported on Windows.");
|
||||
}
|
||||
|
||||
}
|
||||
#elif defined(ATMOSPHERE_OS_LINUX)
|
||||
namespace ams::tipc::impl {
|
||||
|
||||
template<u16 _CommandId, typename ArgumentsTuple>
|
||||
struct CommandMetaInfo;
|
||||
|
||||
template<u16 _CommandId, typename... Arguments>
|
||||
struct CommandMetaInfo<_CommandId, std::tuple<Arguments...>> {
|
||||
public:
|
||||
static constexpr size_t InMessageTotalSize = 0x40; /* TODO */
|
||||
static constexpr size_t OutMessageTotalSize = 0x40; /* TODO */
|
||||
};
|
||||
|
||||
template<typename CommandMeta>
|
||||
class CommandProcessor {
|
||||
public:
|
||||
static ALWAYS_INLINE Result ValidateCommandFormat(const MessageBuffer &) {
|
||||
AMS_ABORT("TODO");
|
||||
}
|
||||
};
|
||||
|
||||
template<u16 _CommmandId, auto ServiceCommandImpl, typename ClassType>
|
||||
ALWAYS_INLINE Result InvokeServiceCommandImpl(ClassType *object, const MessageBuffer &message_buffer) {
|
||||
/* TODO: Is some kind of emulated serialization interesting/desirable? */
|
||||
/* TIPC is generally a huge TODO. */
|
||||
AMS_UNUSED(object, message_buffer);
|
||||
AMS_ABORT("TIPC serialization not currently supported on Linux.");
|
||||
}
|
||||
|
||||
}
|
||||
#elif defined(ATMOSPHERE_OS_MACOS)
|
||||
namespace ams::tipc::impl {
|
||||
|
||||
template<u16 _CommandId, typename ArgumentsTuple>
|
||||
struct CommandMetaInfo;
|
||||
|
||||
template<u16 _CommandId, typename... Arguments>
|
||||
struct CommandMetaInfo<_CommandId, std::tuple<Arguments...>> {
|
||||
public:
|
||||
static constexpr size_t InMessageTotalSize = 0x40; /* TODO */
|
||||
static constexpr size_t OutMessageTotalSize = 0x40; /* TODO */
|
||||
};
|
||||
|
||||
template<typename CommandMeta>
|
||||
class CommandProcessor {
|
||||
public:
|
||||
static ALWAYS_INLINE Result ValidateCommandFormat(const MessageBuffer &) {
|
||||
AMS_ABORT("TODO");
|
||||
}
|
||||
};
|
||||
|
||||
template<u16 _CommmandId, auto ServiceCommandImpl, typename ClassType>
|
||||
ALWAYS_INLINE Result InvokeServiceCommandImpl(ClassType *object, const MessageBuffer &message_buffer) {
|
||||
/* TODO: Is some kind of emulated serialization interesting/desirable? */
|
||||
/* TIPC is generally a huge TODO. */
|
||||
AMS_UNUSED(object, message_buffer);
|
||||
AMS_ABORT("TIPC serialization not currently supported on macOS.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
#error "Unknown OS for tipc Command serialization."
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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 <vapours.hpp>
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
#include <stratosphere/tipc/impl/tipc_impl_message_api.os.horizon.hpp>
|
||||
#elif defined(ATMOSPHERE_OS_WINDOWS)
|
||||
#include <stratosphere/tipc/impl/tipc_impl_message_api.os.windows.hpp>
|
||||
#elif defined(ATMOSPHERE_OS_LINUX)
|
||||
#include <stratosphere/tipc/impl/tipc_impl_message_api.os.linux.hpp>
|
||||
#elif defined(ATMOSPHERE_OS_MACOS)
|
||||
#include <stratosphere/tipc/impl/tipc_impl_message_api.os.macos.hpp>
|
||||
#else
|
||||
#error "Unknown OS for tipc message impl"
|
||||
#endif
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 <vapours.hpp>
|
||||
#include <stratosphere/tipc/tipc_common.hpp>
|
||||
#include <stratosphere/tipc/tipc_message_types.hpp>
|
||||
|
||||
namespace ams::tipc::impl {
|
||||
|
||||
inline void Reply(tipc::NativeHandle reply_target) {
|
||||
/* Perform the reply. */
|
||||
s32 dummy;
|
||||
R_TRY_CATCH(svc::ReplyAndReceive(std::addressof(dummy), nullptr, 0, reply_target, 0)) {
|
||||
R_CATCH(svc::ResultTimedOut) {
|
||||
/* Timing out is acceptable. */
|
||||
}
|
||||
R_CATCH(svc::ResultSessionClosed) {
|
||||
/* It's okay if we couldn't reply to a closed session. */
|
||||
}
|
||||
} R_END_TRY_CATCH_WITH_ABORT_UNLESS;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Result CloseHandle(tipc::NativeHandle handle) {
|
||||
return svc::CloseHandle(handle);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Result CreateSession(tipc::NativeHandle *out_server_session_handle, tipc::NativeHandle *out_client_session_handle, bool is_light, uintptr_t name) {
|
||||
return svc::CreateSession(out_server_session_handle, out_client_session_handle, is_light, name);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Result AcceptSession(tipc::NativeHandle *out_handle, tipc::NativeHandle port) {
|
||||
return svc::AcceptSession(out_handle, port);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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 <vapours.hpp>
|
||||
#include <stratosphere/tipc/tipc_common.hpp>
|
||||
#include <stratosphere/tipc/tipc_message_types.hpp>
|
||||
|
||||
namespace ams::tipc::impl {
|
||||
|
||||
inline void Reply(tipc::NativeHandle reply_target) {
|
||||
AMS_UNUSED(reply_target);
|
||||
AMS_ABORT("TODO: tipc Linux Reply");
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Result CloseHandle(tipc::NativeHandle handle) {
|
||||
AMS_UNUSED(handle);
|
||||
AMS_ABORT("TODO: tipc Linux CloseHandle");
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Result CreateSession(tipc::NativeHandle *out_server_session_handle, tipc::NativeHandle *out_client_session_handle, bool is_light, uintptr_t name) {
|
||||
AMS_UNUSED(out_server_session_handle, out_client_session_handle, is_light, name);
|
||||
AMS_ABORT("TODO: tipc Linux CreateSession");
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Result AcceptSession(tipc::NativeHandle *out_handle, tipc::NativeHandle port) {
|
||||
AMS_UNUSED(out_handle, port);
|
||||
AMS_ABORT("TODO: tipc Linux AcceptSession");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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 <vapours.hpp>
|
||||
#include <stratosphere/tipc/tipc_common.hpp>
|
||||
#include <stratosphere/tipc/tipc_message_types.hpp>
|
||||
|
||||
namespace ams::tipc::impl {
|
||||
|
||||
inline void Reply(tipc::NativeHandle reply_target) {
|
||||
AMS_UNUSED(reply_target);
|
||||
AMS_ABORT("TODO: tipc macOS Reply");
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Result CloseHandle(tipc::NativeHandle handle) {
|
||||
AMS_UNUSED(handle);
|
||||
AMS_ABORT("TODO: tipc macOS CloseHandle");
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Result CreateSession(tipc::NativeHandle *out_server_session_handle, tipc::NativeHandle *out_client_session_handle, bool is_light, uintptr_t name) {
|
||||
AMS_UNUSED(out_server_session_handle, out_client_session_handle, is_light, name);
|
||||
AMS_ABORT("TODO: tipc macOS CreateSession");
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Result AcceptSession(tipc::NativeHandle *out_handle, tipc::NativeHandle port) {
|
||||
AMS_UNUSED(out_handle, port);
|
||||
AMS_ABORT("TODO: tipc macOS AcceptSession");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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 <vapours.hpp>
|
||||
#include <stratosphere/tipc/tipc_common.hpp>
|
||||
#include <stratosphere/tipc/tipc_message_types.hpp>
|
||||
|
||||
namespace ams::tipc::impl {
|
||||
|
||||
inline void Reply(tipc::NativeHandle reply_target) {
|
||||
AMS_UNUSED(reply_target);
|
||||
AMS_ABORT("TODO: tipc Windows Reply");
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Result CloseHandle(tipc::NativeHandle handle) {
|
||||
AMS_UNUSED(handle);
|
||||
AMS_ABORT("TODO: tipc Windows CloseHandle");
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Result CreateSession(tipc::NativeHandle *out_server_session_handle, tipc::NativeHandle *out_client_session_handle, bool is_light, uintptr_t name) {
|
||||
AMS_UNUSED(out_server_session_handle, out_client_session_handle, is_light, name);
|
||||
AMS_ABORT("TODO: tipc Windows CreateSession");
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Result AcceptSession(tipc::NativeHandle *out_handle, tipc::NativeHandle port) {
|
||||
AMS_UNUSED(out_handle, port);
|
||||
AMS_ABORT("TODO: tipc Windows AcceptSession");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user