/* * Copyright (c) 2018 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 . */ #pragma once #include #include #include #include #include "../boost/callable_traits.hpp" #include #include "domainowner.hpp" #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-but-set-variable" /* Base for In/Out Buffers. */ struct IpcBufferBase {}; /* Represents an A descriptor. */ struct InBufferBase : IpcBufferBase {}; template struct InBuffer : InBufferBase { T *buffer; size_t num_elements; BufferType type; static const BufferType expected_type = e_t; InBuffer(void *b, size_t n, BufferType t) : buffer((T *)b), num_elements(n/sizeof(T)), type(t) { } }; /* Represents a B descriptor. */ struct OutBufferBase : IpcBufferBase {}; template struct OutBuffer : OutBufferBase { T *buffer; size_t num_elements; BufferType type; static const BufferType expected_type = e_t; OutBuffer(void *b, size_t n, BufferType t) : buffer((T *)b), num_elements(n/sizeof(T)), type(t) { } }; /* Represents an X descriptor. */ template struct InPointer : IpcBufferBase { T *pointer; size_t num_elements; InPointer(void *p, size_t n) : pointer((T *)p), num_elements(n/sizeof(T)) { } }; /* Represents a C descriptor. */ struct OutPointerWithServerSizeBase : IpcBufferBase {}; template struct OutPointerWithServerSize : OutPointerWithServerSizeBase { T *pointer; static const size_t num_elements = n; OutPointerWithServerSize(void *p) : pointer((T *)p) { } }; /* Represents a C descriptor with size in raw data. */ template struct OutPointerWithClientSize : IpcBufferBase { T *pointer; size_t num_elements; OutPointerWithClientSize(void *p, size_t n) : pointer((T *)p), num_elements(n/sizeof(T)) { } }; /* Represents an input PID. */ struct PidDescriptor { u64 pid; PidDescriptor(u64 p) : pid(p) { } }; /* Represents a moved handle. */ struct MovedHandle { Handle handle; MovedHandle(Handle h) : handle(h) { } }; /* Represents a copied handle. */ struct CopiedHandle { Handle handle; CopiedHandle(Handle h) : handle(h) { } }; /* Forward declarations. */ template class ISession; /* Represents an output ServiceObject. */ struct OutSessionBase {}; template struct OutSession : OutSessionBase { ISession *session; u32 domain_id; OutSession(ISession *s) : session(s), domain_id(DOMAIN_ID_MAX) { } }; /* Utilities. */ template class Template> struct is_specialization_of { static const bool value = false; }; template