From 61e5f320c98e67c5b4f9de0930b5a67d01bb71a9 Mon Sep 17 00:00:00 2001 From: wwylele Date: Thu, 1 Mar 2018 16:37:56 +0200 Subject: [PATCH] ipc_helpers: remove some deprecated functions --- src/core/hle/ipc_helpers.h | 109 +++++++++------------------- src/core/hle/service/fs/fs_user.cpp | 2 +- 2 files changed, 34 insertions(+), 77 deletions(-) diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index 949256433e..b2f8f97179 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h @@ -117,10 +117,7 @@ public: // TODO : ensure that translate params are added after all regular params template - void PushCopyHandles(H... handles); - - template - void PushMoveHandles(H... handles); + [[deprecated]] void PushCopyHandles(H... handles); template void PushCopyObjects(Kernel::SharedPtr... pointers); @@ -131,11 +128,15 @@ public: [[deprecated]] void PushStaticBuffer(VAddr buffer_vaddr, size_t size, u8 buffer_id); void PushStaticBuffer(const std::vector& buffer, u8 buffer_id); - [[deprecated]] void PushMappedBuffer(VAddr buffer_vaddr, size_t size, - MappedBufferPermissions perms); - /// Pushes an HLE MappedBuffer interface back to unmapped the buffer. void PushMappedBuffer(const Kernel::MappedBuffer& mapped_buffer); + +private: + template + void PushCopyHLEHandles(H... handles); + + template + void PushMoveHLEHandles(H... handles); }; /// Push /// @@ -186,24 +187,29 @@ void RequestBuilder::Push(const First& first_value, const Other&... other_values template inline void RequestBuilder::PushCopyHandles(H... handles) { - Push(CopyHandleDesc(sizeof...(H))); - Push(static_cast(handles)...); + PushCopyHLEHandles(handles...); } template -inline void RequestBuilder::PushMoveHandles(H... handles) { +inline void RequestBuilder::PushCopyHLEHandles(H... handles) { + Push(CopyHandleDesc(sizeof...(H))); + Push(static_cast(handles)...); +} + +template +inline void RequestBuilder::PushMoveHLEHandles(H... handles) { Push(MoveHandleDesc(sizeof...(H))); - Push(static_cast(handles)...); + Push(static_cast(handles)...); } template inline void RequestBuilder::PushCopyObjects(Kernel::SharedPtr... pointers) { - PushCopyHandles(context->AddOutgoingHandle(std::move(pointers))...); + PushCopyHLEHandles(context->AddOutgoingHandle(std::move(pointers))...); } template inline void RequestBuilder::PushMoveObjects(Kernel::SharedPtr... pointers) { - PushMoveHandles(context->AddOutgoingHandle(std::move(pointers))...); + PushMoveHLEHandles(context->AddOutgoingHandle(std::move(pointers))...); } inline void RequestBuilder::PushStaticBuffer(VAddr buffer_vaddr, size_t size, u8 buffer_id) { @@ -221,12 +227,6 @@ inline void RequestBuilder::PushStaticBuffer(const std::vector& buffer, u8 b context->AddStaticBuffer(buffer_id, buffer); } -inline void RequestBuilder::PushMappedBuffer(VAddr buffer_vaddr, size_t size, - MappedBufferPermissions perms) { - Push(MappedBufferDesc(size, perms)); - Push(buffer_vaddr); -} - inline void RequestBuilder::PushMappedBuffer(const Kernel::MappedBuffer& mapped_buffer) { Push(mapped_buffer.GenerateDescriptor()); Push(mapped_buffer.GetId()); @@ -284,24 +284,6 @@ public: return static_cast(Pop>()); } - /// Equivalent to calling `PopHandles<1>()[0]`. - Kernel::Handle PopHandle(); - - /** - * Pops a descriptor containing `N` handles. The handles are returned as an array. The - * descriptor must contain exactly `N` handles, it is not permitted to, for example, call - * PopHandles<1>() twice to read a multi-handle descriptor with 2 handles, or to make a single - * PopHandles<2>() call to read 2 single-handle descriptors. - */ - template - std::array PopHandles(); - - /// Convenience wrapper around PopHandles() which assigns the handles to the passed references. - template - void PopHandles(H&... handles) { - std::tie(handles...) = PopHandles(); - } - /// Equivalent to calling `PopGenericObjects<1>()[0]`. Kernel::SharedPtr PopGenericObject(); @@ -311,8 +293,10 @@ public: /** * Pop a descriptor containing `N` handles and resolves them to Kernel::Object pointers. If a - * handle is invalid, null is returned for that object instead. The same caveats from - * PopHandles() apply regarding `N` matching the number of handles in the descriptor. + * handle is invalid, null is returned for that object instead. The descriptor must contain + * exactly `N` handles, it is not permitted to, for example, call PopGenericObjects<1>() twice + * to read a multi-handle descriptor with 2 handles, or to make a single PopGenericObjects<2>() + * call to read 2 single-handle descriptors. */ template std::array, N> PopGenericObjects(); @@ -355,17 +339,6 @@ public: */ const std::vector& PopStaticBuffer(); - /** - * @brief Pops the mapped buffer vaddr - * @return The virtual address of the buffer - * @param[out] data_size If non-null, the pointed value will be set to the size of the data - * given by the source process - * @param[out] buffer_perms If non-null, the pointed value will be set to the permissions of the - * buffer - */ - [[deprecated]] VAddr PopMappedBuffer(size_t* data_size, - MappedBufferPermissions* buffer_perms = nullptr); - /// Pops a mapped buffer descriptor with its vaddr and resolves it to an HLE interface Kernel::MappedBuffer& PopMappedBuffer(); @@ -382,6 +355,10 @@ public: */ template T PopRaw(); + +private: + template + std::array PopHLEHandles(); }; /// Pop /// @@ -443,32 +420,23 @@ void RequestParser::Pop(First& first_value, Other&... other_values) { Pop(other_values...); } -inline Kernel::Handle RequestParser::PopHandle() { - const u32 handle_descriptor = Pop(); - DEBUG_ASSERT_MSG(IsHandleDescriptor(handle_descriptor), - "Tried to pop handle(s) but the descriptor is not a handle descriptor"); - DEBUG_ASSERT_MSG(HandleNumberFromDesc(handle_descriptor) == 1, - "Descriptor indicates that there isn't exactly one handle"); - return Pop(); -} - template -std::array RequestParser::PopHandles() { +std::array RequestParser::PopHLEHandles() { u32 handle_descriptor = Pop(); ASSERT_MSG(IsHandleDescriptor(handle_descriptor), "Tried to pop handle(s) but the descriptor is not a handle descriptor"); ASSERT_MSG(N == HandleNumberFromDesc(handle_descriptor), "Number of handles doesn't match the descriptor"); - std::array handles{}; - for (Kernel::Handle& handle : handles) { - handle = Pop(); + std::array handles{}; + for (u32& handle : handles) { + handle = Pop(); } return handles; } inline Kernel::SharedPtr RequestParser::PopGenericObject() { - Kernel::Handle handle = PopHandle(); + auto[handle] = PopHLEHandles<1>(); return context->GetIncomingHandle(handle); } @@ -479,7 +447,7 @@ Kernel::SharedPtr RequestParser::PopObject() { template inline std::array, N> RequestParser::PopGenericObjects() { - std::array handles = PopHandles(); + std::array handles = PopHLEHandles(); std::array, N> pointers; for (int i = 0; i < N; ++i) { pointers[i] = context->GetIncomingHandle(handles[i]); @@ -524,17 +492,6 @@ inline const std::vector& RequestParser::PopStaticBuffer() { return context->GetStaticBuffer(buffer_info.buffer_id); } -inline VAddr RequestParser::PopMappedBuffer(size_t* data_size, - MappedBufferPermissions* buffer_perms) { - const u32 sbuffer_descriptor = Pop(); - MappedBufferDescInfo bufferInfo{sbuffer_descriptor}; - if (data_size != nullptr) - *data_size = bufferInfo.size; - if (buffer_perms != nullptr) - *buffer_perms = bufferInfo.perms; - return Pop(); -} - inline Kernel::MappedBuffer& RequestParser::PopMappedBuffer() { u32 mapped_buffer_descriptor = Pop(); ASSERT_MSG(GetDescriptorType(mapped_buffer_descriptor) == MappedBuffer, diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index c65943a724..d39b76f455 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -100,7 +100,7 @@ void FS_USER::OpenFileDirectly(Kernel::HLERequestContext& ctx) { "Failed to get a handle for archive archive_id=0x%08X archive_path=%s", static_cast(archive_id), archive_path.DebugStr().c_str()); rb.Push(archive_handle.Code()); - rb.PushMoveHandles(0); + rb.PushMoveObjects(nullptr); return; } SCOPE_EXIT({ Service::FS::CloseArchive(*archive_handle); });