summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-02-14 03:41:20 +0100
committerbunnei <bunneidev@gmail.com>2018-02-14 05:26:03 +0100
commit1ce6fff0648008b7510e9feb3cf6696a2c25dd5c (patch)
tree879c69e708657d93a3c69717ae989350894ca285 /src/core/hle/kernel
parentvi: Fix TransactParcelAuto to support both buffer formats. (diff)
downloadyuzu-1ce6fff0648008b7510e9feb3cf6696a2c25dd5c.tar
yuzu-1ce6fff0648008b7510e9feb3cf6696a2c25dd5c.tar.gz
yuzu-1ce6fff0648008b7510e9feb3cf6696a2c25dd5c.tar.bz2
yuzu-1ce6fff0648008b7510e9feb3cf6696a2c25dd5c.tar.lz
yuzu-1ce6fff0648008b7510e9feb3cf6696a2c25dd5c.tar.xz
yuzu-1ce6fff0648008b7510e9feb3cf6696a2c25dd5c.tar.zst
yuzu-1ce6fff0648008b7510e9feb3cf6696a2c25dd5c.zip
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp39
-rw-r--r--src/core/hle/kernel/hle_ipc.h12
2 files changed, 51 insertions, 0 deletions
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index db104e8a2..a5a3d4fe4 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -12,6 +12,7 @@
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/process.h"
#include "core/hle/kernel/server_session.h"
+#include "core/memory.h"
namespace Kernel {
@@ -210,4 +211,42 @@ ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, P
return RESULT_SUCCESS;
}
+std::vector<u8> HLERequestContext::ReadBuffer() const {
+ std::vector<u8> buffer;
+ const bool is_buffer_a{BufferDescriptorA().size() && BufferDescriptorA()[0].Size()};
+
+ if (is_buffer_a) {
+ buffer.resize(BufferDescriptorA()[0].Size());
+ Memory::ReadBlock(BufferDescriptorA()[0].Address(), buffer.data(), buffer.size());
+ } else {
+ buffer.resize(BufferDescriptorX()[0].Size());
+ Memory::ReadBlock(BufferDescriptorX()[0].Address(), buffer.data(), buffer.size());
+ }
+
+ return buffer;
+}
+
+size_t HLERequestContext::WriteBuffer(const void* buffer, const size_t size) const {
+ const bool is_buffer_b{BufferDescriptorB().size() && BufferDescriptorB()[0].Size()};
+
+ if (is_buffer_b) {
+ const size_t size{std::min(BufferDescriptorB()[0].Size(), size)};
+ Memory::WriteBlock(BufferDescriptorB()[0].Address(), buffer, size);
+ return size;
+ } else {
+ const size_t size{std::min(BufferDescriptorC()[0].Size(), size)};
+ Memory::WriteBlock(BufferDescriptorC()[0].Address(), buffer, size);
+ return size;
+ }
+}
+
+size_t HLERequestContext::WriteBuffer(const std::vector<u8>& buffer) const {
+ return WriteBuffer(buffer.data(), buffer.size());
+}
+
+size_t HLERequestContext::GetWriteBufferSize() const {
+ const bool is_buffer_b{BufferDescriptorB().size() && BufferDescriptorB()[0].Size()};
+ return is_buffer_b ? BufferDescriptorB()[0].Size() : BufferDescriptorC()[0].Size();
+}
+
} // namespace Kernel
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h
index da8335b35..0cc270909 100644
--- a/src/core/hle/kernel/hle_ipc.h
+++ b/src/core/hle/kernel/hle_ipc.h
@@ -143,6 +143,18 @@ public:
return domain_message_header;
}
+ /// Helper function to read a buffer using the appropriate buffer descriptor
+ std::vector<u8> ReadBuffer() const;
+
+ /// Helper function to write a buffer using the appropriate buffer descriptor
+ size_t WriteBuffer(const void* buffer, const size_t size) const;
+
+ /// Helper function to write a buffer using the appropriate buffer descriptor
+ size_t WriteBuffer(const std::vector<u8>& buffer) const;
+
+ /// Helper function to get the size of the output buffer
+ size_t GetWriteBufferSize() const;
+
template <typename T>
SharedPtr<T> GetCopyObject(size_t index) {
ASSERT(index < copy_objects.size());